A smoothed-looking pdf file becomes a pixelated png file.
A smoothed-looking pdf file becomes a pixelated png file.
Hi everyone,
A smoothed-looking pdf file becomes a pixelated png file when I convert the pdf file using convert command.
I produced a .ps file, and I converted it into a pdf file using ghostscript command ps2pdf.
Although the original .grd file has coarse pixels, my plots in pdf and ps formats look smooth.
But when I converted the smoothed-looking pdf or ps files into a png file, it became pixelated with the same coarse pixels in my original .grd input.
Is there anyway to keep the same smoothness when I convert a pdf file into a png file?
Thanks in advance!
A smoothed-looking pdf file becomes a pixelated png file when I convert the pdf file using convert command.
I produced a .ps file, and I converted it into a pdf file using ghostscript command ps2pdf.
Although the original .grd file has coarse pixels, my plots in pdf and ps formats look smooth.
But when I converted the smoothed-looking pdf or ps files into a png file, it became pixelated with the same coarse pixels in my original .grd input.
Is there anyway to keep the same smoothness when I convert a pdf file into a png file?
Thanks in advance!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: A smoothed-looking pdf file becomes a pixelated png file.
ImageMagick uses Ghostscript to process PDFs. But Ghostscript does not preserve vector information. It rasterizes it. That explains why that happens. Add -density 300 before reading the PDF and that should make it higher resolution.
______________
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
______________
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: A smoothed-looking pdf file becomes a pixelated png file.
As Fred says.
The "-density" number can be as large as you want, to make the rasterised image as smooth as you want (and also larger).
The "-density" number can be as large as you want, to make the rasterised image as smooth as you want (and also larger).
snibgo's IM pages: im.snibgo.com
Re: A smoothed-looking pdf file becomes a pixelated png file.
Sorry for missing details.
Here is the version information.
Version: ImageMagick 7.0.8-9 Q16 x86_64 2018-08-04 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI
Delegates (built-in): bzlib freetype jng jpeg lcms png raw tiff webp xml zlib
I use MacOS X Mojave.
on the terminal I computed,
"convert -density 300 original_file.ps 3.png"
and "convert -density 300 original_file.pdf -density 300 2.png"
Do you know how to upload an image from my local machine? I wish I could attach one image. It didn't work
(look at the box with a question mark below)
Here is the version information.
Version: ImageMagick 7.0.8-9 Q16 x86_64 2018-08-04 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI
Delegates (built-in): bzlib freetype jng jpeg lcms png raw tiff webp xml zlib
I use MacOS X Mojave.
on the terminal I computed,
"convert -density 300 original_file.ps 3.png"
and "convert -density 300 original_file.pdf -density 300 2.png"
Do you know how to upload an image from my local machine? I wish I could attach one image. It didn't work
(look at the box with a question mark below)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: A smoothed-looking pdf file becomes a pixelated png file.
You must upload to some free hosting service and the put the URL here. If you post images, then post the originals also.
IM 7.0.8.9 is rather old. Currently at 7.0.8.36. Perhaps you should upgrade and test again.
IM 7.0.8.9 is rather old. Currently at 7.0.8.36. Perhaps you should upgrade and test again.
Re: A smoothed-looking pdf file becomes a pixelated png file.
You can check the figures at the following URL : https://kjhttr.wixsite.com/kjhttr
Sorry for the bad quality. But at least you can see the difference between the pdf image and the png images.
Sorry for the bad quality. But at least you can see the difference between the pdf image and the png images.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: A smoothed-looking pdf file becomes a pixelated png file.
The PNG samples show posterisation of the background colours. The commands you show above cannot cause that posterisation.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: A smoothed-looking pdf file becomes a pixelated png file.
It would always be best if you post images separately so we can test with them.
Re: A smoothed-looking pdf file becomes a pixelated png file.
https://www.dropbox.com/sh/gaq5bpor1rcm ... dluEa?dl=0
---------------------------------------------------------------------------------------------------------
I uploaded an original postscript on a dropbox directory. I took a screen shot as well and uploaded it together.
Note that the png file is a screen shot I took in order to show you how this looks like.
You can download them at the URL provided above.
What I found so far is that the original ps file looks smooth if I use Preview.app in my Mac.
However, on the website, it is pixelated. If I download it and open it again, it looks smooth.
I used gs command to open it using a PC where Ubuntu is installed. It looks pixelated.
I generated the figure using Generic Mapping Tools. Because of one GMT command that I used, this plot is supposed to look smooth as I see it using
Preview.app.
If you think this problem is not related to magick convert, let me know then I will delete this thread.
Thank you a lot, snibgo and tmw42.
---------------------------------------------------------------------------------------------------------
I uploaded an original postscript on a dropbox directory. I took a screen shot as well and uploaded it together.
Note that the png file is a screen shot I took in order to show you how this looks like.
You can download them at the URL provided above.
What I found so far is that the original ps file looks smooth if I use Preview.app in my Mac.
However, on the website, it is pixelated. If I download it and open it again, it looks smooth.
I used gs command to open it using a PC where Ubuntu is installed. It looks pixelated.
I generated the figure using Generic Mapping Tools. Because of one GMT command that I used, this plot is supposed to look smooth as I see it using
Preview.app.
If you think this problem is not related to magick convert, let me know then I will delete this thread.
Thank you a lot, snibgo and tmw42.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: A smoothed-looking pdf file becomes a pixelated png file.
Using ImageMagick 6.9.10.36 or 7.0.8.36 and density 300 and Ghostscript 9.25, your image converts to png without issue and looks fine to me, no jagged edges as far as I can tell.
For IM 7, use magick only, not convert and not magick convert.
I suspect you may have an issue with Ghostscript. What is your version. If 9.26, downgrade, since that one seems to have some bugs. I believe that 9.23, 9.24, and 9.25 are likely fine.
Code: Select all
convert -density 300 original.ps original.png
I suspect you may have an issue with Ghostscript. What is your version. If 9.26, downgrade, since that one seems to have some bugs. I believe that 9.23, 9.24, and 9.25 are likely fine.
Re: A smoothed-looking pdf file becomes a pixelated png file.
Hi
It turned out that I had an issue when I generated the postscript file.
I regenerated it and converted it using
magick mogrify -format png -density 300 *.ps
and
convert -density 300 original.ps original.png
They both look great.
Thanks for helping me.
It turned out that I had an issue when I generated the postscript file.
I regenerated it and converted it using
magick mogrify -format png -density 300 *.ps
and
convert -density 300 original.ps original.png
They both look great.
Thanks for helping me.