I'm using Ghostcript to convert some PDF files to JPG. All is working when converting the program consider the resolution of 600dpi when converting and output jpeg quality is good.
Here is my code :
gs -sDEVICE=jpegcmyk -dTextAlphaBits=4 -r600 -dSAFER -dBATCH -dNOPAUSE -o my_output_file.jpg my_input_file.pdf
But when I open the file in Photoshop, the properties contains 72dpi instead of 600dpi I expected :
When I try with RGB profile for output, it is ok, I have got 600dpi.
So what I want is CMYK + 600dpi in image properties.
As can be seen from your screenshots, both images are of the same dimensions, 6803 by 709 pixels.
And that is all that matters.
Also, the size of the CMYK version is bigger by about 33% compared to the RGB version -- as is to be expected for an image with 4 color channels instead of 3.
Ghostscript used the -r600 CLI parameter to correctly expand the number of pixels when converting the PDF file.
Ghostscript does not add any EXIF metadata to its output when converting a PDF to raster.
The DPI or PPI information would be an internal metadata hint to tell any compliant viewers how big to render the image on screen. It would not change anything substantial in the image information itself.
Why Photoshop does think it should use 72 dpi for one, but 600 dpi for the other, you may ask Adobe about.
I bet Photoshop also renders the 72dpi file about 7 times larger on screen than the other. Is that the case?
P.S.: See also "What DPI do web images need to be?"
Related
I can use Acrobat to reduce a PDF file of 30MB to 10MB. The input PDF is just the result of combining of many monochrome tiff files like the following.
$ file x.tiff
x.tiff: TIFF image data, little-endian, direntries=14, height=2957, bps=1, compression=bi-level group 4, PhotometricIntepretation=WhiteIsZero, orientation=upper-left, width=1627
The tiff files are converted to pdf files using the following command.
convert x.tiff x.pdf
The single page PDF files are then merged to a single PDF file by the following command.
cpdf input1.pdf input2.pdf ... -o output.pdf
The OCR (Searchable Image (Exact)) is done on the pdf file. I am surprized that the file size can be reduced to only 1/3.
Note that I don't see any changes in image resolution. For example, when I zoom in, I see squares for pixels. The image in pdf still looks black-white, there are no gray pixels.
What can be done to reduce the PDF files by such a big amount?
You may want to run the PDF through pdfsizeopt. For such a PDF, pdfsizeopt will most probably recompress the images with JBIG2 compression, which makes them smaller without loss of quality or reducing the image resolution. However, it's unlikely that this will make the PDF much smaller than by a factor of 3.
pdfsizeopt --use-pngout=no output.pdf optimized_output.pdf
If you need an even smaller PDF, you may want to reduce the image resolution (number of image pixels) first (before running pdfsizeopt):
convert x.tiff -resize 50% x.pdf
If you are unsure what is using much space in a PDF, run:
pdfsizeopt --stats output.pdf
I have an image of a website which I'm trying to convert to PDF. I have the image in several formats: PSD, PNG, JPG, TIFF, all saved losslessly.
I'm using the following command to convert the image to PDF:
convert -density 93 foo.jpg bar.pdf
Here is part of the original image:
And here is the same part, after converting to PDF:
As you can see, the second one is ever so slightly hazy. What's causing this, and how can I eliminate it? I've seen PDFs with crisp graphics, so I know it's possible.
If you are seeing the same results with multiple input types. The fuzziness is likely being caused by the anti-aliasing feature of your PDF Viewer. If using Acrobat, you can turn off image anti-aliasing by doing the following:
Go to Edit-->Preferences-->Page Display
Untick the option "Smooth Images" and hit "OK".
The crisp graphics you are seeing on other PDFs are likely due to the fact that they are vectorized graphics. Imagemagick is creating a PDF and embedding your image inside of it which may be subject to compression.
Also:
When using jpeg as input, add the "-quality 100" to your Imagemagick call to retain the highest quality possible.
Use a higher value for the "-density" parameter (I would recommend at least 150) to generate a higher resolution PDF.
The ImageMagick (IM) result of this command
convert myRGB.png -colorspace cmyk cmyk.pdf <br>
is not as bright or as close to the screen colors as a Photoshop produced CMYK PDF. myRGB.png is a PNG file produced using GIMP.
I don't own Photoshop, and would like to stick with open source tools.
The current Ubuntu release of of IM is 6.7.7. That IM version produces very dark, totally unusable, CMYK PDF.
I built 7.0.2-6 Q16 from source on Ubuntu 14.0.4, after also building LCMS package from source, and the above command works better, but the CMYK PDF as stated above is less bright and less close to the screen colors than the similar Photoshop output. E.g. blacks are not totally black; the sky color is dull blue instead of bright blue/cyan.
I've tried using ICC files downloaded from Adobe as in the following
convert myRGB.png -colorspace cmyk -profile WebCoatedSWOP2006Grade5.icc cmyk.pdf
I've tried this command with all 14 Adobe ICC files and there is no difference in any of them. Although, I admit I do not understand under what circumstances the ICC comes into play or if it is appropriate to this problem at all.
The simple question is why does IM convert tool not match the Photoshop results for CMYK?
The second question is, if IM can't be made to do it: is there any open source tool or tools that can match the Photoshop results for producing a CMYK PDF from and RGB PNG?
There are two applications involved, as you presumably know since you tagged this with Ghostscript. You haven't said which version of Ghostscript you have installed but the first thing I would do is remove ImageMagick from the equation.
Find out whether IM is having Ghostscript produce RGB or CMYK output, my bet is that it is getting RGB from GS. You'll need to find out what Ghostscript command line IM is using and I can't tell you how to do that. Assuming that the Ghostscript output is RGB then this would explain why altering the IM settings makes no difference.
Proceeding on the assumption that the above is correct, use the png16m device in Ghostscript to produce RGB PNG files directly, this reduces the scope of the problem:
gs -sDEVICE=png16m -o out.png input.pdf
Now, you don't say what version of Ghostscript you have installed, but assuming its relatively recent you can look in the /ghostpdl/doc directory and find considerable information on using colour management in Ghostscript, the document GS9_Color_Management.pdf may be helpful. It will certainly give you a myriad of opportunities to alter the output.
I need to extract vector graphics from a PDF image and import them into GIMP, either as paths or as high-resolution raster images. Specifically, I need to get contour lines from USGS topographical maps and overlay them on satellite images. Any suggestions?
So far I have tried:
--Using GIMP's native PDF importing function to import them as raster images. Problem: To do so at high resolution crashes my computer. Possible solution would be to import only a selected area of a PDF, but as far as I can tell this is not possible.
--Using ImageMagick to convert the PDF to a raster image. Problem: Used with the "-scale" parameter, "convert" appears to rasterize the PDF and then upscale it, leading to a choppy image.
--Using InkScape to extract the necessary vector elements from the PDF. Problem: InkScape freezes when I try to open a moderately large (25 Mb) PDF.
Any other ideas?
Many thanks,
treacl
The option you didn't mention above is to try to use the ghostscript program directly to render your output - ghostscript is used internally by GIMP to import PDF files, so you likely have it installed already.
There are tens of command switches to pass ghostscript for it to render a file into another format - the switches you need to pass are for determining the output size, resolution and which page to print. I didn't find any switch to select a portion of the page to be rendered - so, if your document is a single page, it is possible the generated file will still be to big for GIMP - but you will likely be able to crop it with ImageMagick, at least.
I guess the relevant command line for you would be something along:
gs -dNOPAUSE -dBATCH -sDEVICE=png16m -sOutputFile=page.png -dFirstPage=<pagenumber> -dLastPage=<pagenumber> -r<dpiresolution> -f<filename.pdf>
If the resulting image is still too large to be generated or operated upon, you can try changing the output format to use a smaller color depth (this one is 3 bytes per pixel: png16m) . It should be possible to pass postscript commands to transform the device, so that the area of interest is scaled up to your page size (and the remaining parts are cropped out of the rendering) - that would be the definitive fix for you - but of the top of my head, I don't know how to do that with ghostscript.
Alternatively, you can try passing ImageMagick the -density parameter as suggested in the comments.
I'm converting pdf (created with adobe illustrator) into transparent png file, with following command:
gs -q -sDEVICE=pngalpha -r300 -o target.png -f source.pdf
However, there's undesired white boxes in the resulting PNG, looks like it's auto generated by ghostscript, some bounding box. (see attached image)
Tryied both gs-9.05 and gs-9.10, same bad result.
I've tried to export to PNG file from Illustrator or Inkscape manually, the result is good.
What does Inkscape do to render it correct, and
How could I eliminate those white boxes using ghostscript?
Try mudraw of latest (1.3) muPDF, as far as I checked it creates nice PNGs from PDF files with 1.4 transparency:
mudraw -o out.png -c rgba in.pdf
"rgba" being, as you understand, RGB + alpha
In the general case, you can't. PDF does support transparency, but the underlying media is always assumed to be white and opaque. So anywhere that marks are made on the medium is no longer transparent, its white.
You don't say which version of Ghostscript you are using, but if its earlier than 9.10 you could try upgrading.