When you zoom in PDF, text will not be distorted, the image distortion.
How to make the picture enlarged without distortion, But don't vector map.
the problem that you are facing is about your image's DPI. Most PDF viewers draw the image at a fixed dpi regardless of the image's dpi. My guess is you are using a 150 dpi or so. Try playing with the dpi value to find a good fit for the area you are trying to draw your image into and the size of the original image.
Also make sure your original image is big enough for the area you are trying to cover.
Related
I am new in android studio... I was searching as to how i can convert the dimensions of an image. I found out that you need to get the DPI. My question is will it be possible to convert the unit of the image, to inches, without knowing the DPI?? I tried using .getheight() and .getwidth() and it does give me the resolution, my problem is I need to convert this to inches. Also, I saw this "dp" in imageview... I'm wondering wheter this has an equivalent value in inches that I can use to convert my image using ratio and proportion. Also found out bitmap.getdensity(). Does that get the actual dpi of the image??
How to get image dimension in inches without knowing the DPI?
The question doesn't make much sense.
In general, a digital image has no inherent size in inches, or an inherent DPI (dots per inch). It has a size in pixels (or dots).
The DPI is actually a property of the device you are displaying the image on. For an image that is displayed, you multiply the DPI of the device by the number of pixels in the height or width of the image to give you the height / width of the image on the screen. (If the image has been scaled, the scaling factor needs to be taken into account too.)
In the case of images produced by digital cameras, the metadata of the image may include a "resolution height DPI" and "resolution width DPI". I couldn't find a explanation of what these are supposed to mean, but I surmise that they are either
the physical resolution of the capture device (e.g. CCD), or
a value chosen by the creator of the image to give you their preferred image size.
Neither of these is of much relevance when you are displaying an image. (IMO)
There are about 100 jpeg & png color images used in our JavaFX-built desktop app which, when the window is resized, become stretched and blurry so I'd like to have all the graphics remade in a format that will allow them to be dynamically resized without losing quality. What image format or procedure should be used to do this?
Currently, each image is simply in an ImageView and resized as follows, but I'm open to other suggestions:
if(isSmall){
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
double sh = visualBounds.getHeight();
Scale scale = new Scale(sh, sh, 0, 0);
root.getTransforms().setAll(scale);
}
As has already been mentioned SVG is probably the way to go for you. JavaFX does not support SVG directly but you can find support here
javafxsvg and here svg-to-fxml-converter for example.
You can't resize an image to be bigger than it is without it getting blurry for most common formats. Instead make sure your images are big enough so you only need to downscale them.
The only format I ever heard of that could upscale further was using fractal compression, but AFAIK it is not in common use.
I want to add the following png image to my pdf:
I use following code to do it:
Image img = PngImage.getImage(filename);
img.setBorder(Image.NO_BORDER);
img.setAlignment(Element.ALIGN_CENTER);
img.scaleAbsolute(width,height);
document.add(img);
The image contains a bar graph which has no outer border. When I add the image to my pdf, it shows an outer border, but only for the bottom, left and top sides:
I want to remove border in the pdf, but the above code, does not make that happen.
I am using iText-2.1.5.
In the comments, I claimed that your original image does have a border. You claim it doesn't have a border. Now that you've shared the image, we can check the facts to see who is right.
As it turns out, I was right. When I open the image in GIMP, I clearly see a transparent border:
Maybe you don't see it, because you are looking at the image in Paint or maybe you consider "transparent" and "white" to be the same color. Obviously that assumption is wrong.
I created a PDF containing the image you shared and when I open this PDF using iText RUPS, I see something like this:
PNG is not supported in ISO-32000-1 (aka the PDF specification), hence software that wants to introduce a PNG into a PDF file needs to convert that PNG to another format. In the case of iText, "normal" PNGs are converted to a bitmap with filter /FlateDecode.
In your case, you have a PNG with tranparency. In ISO-32000-1, transparent images are always stored as two images: you have the opaque image (in my screen shot, /Img1 with object number 2) and the image mask (in my screen shot, /Img0 with object number 1).
If you look closely at the image mask (the image that makes the opaque image transparent), you see that it's a black and white image that shows a very small border. This image is shown in the lower-right panel where it says "Stream" (this is where the image stream is rendered). This very small border is the transparent border we can also see in the GIMP (or other image viewers that support transparent images).
If this border is transparent, then why do you see it in a PDF viewer? Well, this border is treated as a line with zero width. In PDF viewers, a line with zero width is shown using the smallest width that can be shown on the device that is being used to view the PDF. If you zoom into the PDF, you'll notice that the width of the line remains constant.
Summarized: you claimed that your image didn't have any border, and that a border was added by iText. I have proven you wrong: the image does have a transparent border and iText correctly introduces this transparent border as a mask. The PDF viewer shows this border as a zero-width line in accordance with ISO-32000-1.
You can solve your problem by removing the transparent border in the original image. For example: I flattened the image using the GIMP. The result is this image:
This image no longer has a transparent border and when you introduce it into a PDF, no border is shown, and no mask is added to the PDF:
I'm using the itext PDF library to build a very image-intensive PDF document in Java. Each page has a dozen images on it. The original source images are very high resolution, and I'm using scaleToFit to render the image to the size I need.
The problem I have is that the PDF document is still very large. My understanding is that the entire original high resolution image is being included, and the scaling I'm using only affects the actual rendering, not the size of the image that's included in the file.
I've verified this by removing the scaling — the pages were rendered with the high resolution images overlapping each other and the edge of pages, and the PDF was the same size as when the scaling was in place.
So, here's the question — how can I reduce the size of the PDF file by scaling down each image? If I lose a little bit of image quality that's ok. Rescaling the source images manually will be difficult.
So I've found a way to do it. I now load the image into a BufferedImage, and then scale that using the hints found here: how do I scale a BufferedImage.
This gives me a BufferedImage — I then convert this into an iText image using
Image returnedImage = Image.getInstance ( pcb, bufferedImage, quality );
Where quality is currently 0.6. That's acceptable for the work I'm doing.
This is what I need to do. I need to create square thumbnails from a standard photo. The photos are usually portrain layout, so I need to shave off the bottom part of the photo so that the height is equals to the width.
If the image is landscape layout then I need to shave off equal number of pixels from left and right to make it square.
Any ideas how to do this?
My image is BufferedImage object already.
You can use getSubimage to retrieve a cropped version of the original image.