Convert - keep the resolution

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Albireo
Posts: 68
Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309

Convert - keep the resolution

Post by Albireo »

Hi!

I have an "jpg" image with size: 600x600pixels, Resolution: 150 dpi
the image get rounded corners with the command. It's OK!
The final image is a ". gif" file (.jpg doesn't work)

The size is 120x120 - OK!
But I can't see the result resolution in IrfanView but the size is the same 120x120pixels

This command works for me (It's only the main code)

Code: Select all

FileIn = 61141_a.jpg
FileOut = 61141_a.gif
PicSize = 120x120     ; pic size out
RCPic = 15     ; rounded corner

%ImageMagick%\convert
		-define "jpeg:size=%PicSize%" %FileIn%
		-thumbnail "%PicSize%>"
		( +clone  -threshold -1
		-draw "fill black polygon 0,0 0,%RCPic% %RCPic%,0
		fill white circle %RCPic%,%RCPic% %RCPic%,0"
		( +clone -flip ) -compose Multiply -composite
		( +clone -flop ) -compose Multiply -composite )
		+matte -compose CopyOpacity -composite -background transparent
		-gravity center -compose Over -extent %PicSize% %FileOut%

Where can I put in this information without destroy something else?

Code: Select all

-density 30x30 -units pixelspercentimeter (or pixelsperinch)
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Convert - keep the resolution

Post by el_supremo »

The GIF format does not include the resolution (density) of the image.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Albireo
Posts: 68
Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309

Re: Convert - keep the resolution

Post by Albireo »

el_supremo wrote:The GIF format does not include the resolution (density) of the image.....
Hmmm. the GIF-images have an resolution or....?

I noticed a "strange" thing.
Created a png file instead of gif - the picture looked good (same size),
but IrfanView said that the image had a resolution of 2x2dpi ....

Can you use "-density 30x30 -units pixelspercentimeter " on png-files?
(and where to insert the instruction?)

//Jan
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Convert - keep the resolution

Post by el_supremo »

Hmmm. the GIF-images have an resolution or....?
or nothing. There is no resolution information stored in a GIF image.
Can you use "-density 30x30 -units pixelspercentimeter " on png-files?
(and where to insert the instruction?)
Yes, PNG stores resolution information in pixels per centimetre. If you specify it in inches, IM will convert it.

I think you would specify it immediately before %FileOut%. You might have to specify the units first - "-units pixelspercentimeter -density 30x30 %FileOut%".

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Albireo
Posts: 68
Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309

Re: Convert - keep the resolution

Post by Albireo »

Thank you!
el_supremo wrote:..........I think you would specify it immediately before %FileOut%. You might have to specify the units first - "-units pixelspercentimeter -density 30x30 %FileOut%".
Pete
No :( , IrfanView shows still 2dpi x 2dpi
//jan
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Convert - keep the resolution

Post by el_supremo »

No :( , IrfanView shows still 2dpi x 2dpi
I don't know how that's happening.
I created a 30 ppcm image with this command:

Code: Select all

convert logo: -units pixelspercentimeter -density 30x30 logo_den.png
Paint Shop Pro reports that the image is indeed 30 ppcm. IrfanView reports that it is 76 dpi which is the correct conversion from ppcm to dpi.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Albireo
Posts: 68
Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309

Re: Convert - keep the resolution

Post by Albireo »

Thank you!

I have used your example of a "simple" image.
This "trial" gave a resolution of 300x300dpi - the file size was: 26KB

Code: Select all

convert -define jpeg:size=120x120 7748790.jpg -thumbnail "120x120>" 774879_120.png
and if I add the "density information" to the command, was the resolution: 76x76dpi.

Code: Select all

convert -define jpeg:size=120x120 7748790.jpg -thumbnail "120x120>" -units pixelspercentimeter -density 30x30 774879_120.png
But the file size was still 26kB
- I would have expected that the file size would reduce with lower resolution....

//Jan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert - keep the resolution

Post by fmw42 »

density has no bearing on the file size. it only controls how the pixels are converted to print to make the print larger or smaller in physical dimensions such as inches or centimeters
Albireo
Posts: 68
Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309

Re: Convert - keep the resolution

Post by Albireo »

fmw42 wrote:density has no bearing on the file size. it only controls how the pixels are converted to print to make the print larger or smaller in physical dimensions such as inches or centimeters
hmmm. The print to the printer or the print on the screen?
Why don't use high density everywhere?

I have read somewhere that, the best resolution for the webpages is 72dpi
(if the image size don't increase - why don't use 300, 600 or 1200dpi on the images on webpages?)
The prints could be better from the website?

Have I been thinking wrong? :?

//Jan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert - keep the resolution

Post by fmw42 »

density only affects hard copy print and not the display. the nominal density for images is 72 dpi, but that has no bearing on an image displayed or put on a web page. The only issue is the pixel width and height of the image. the number of pixels in width and the density then determine how many inches it will print to. For 1000 pixels at 72 dpi it will print only (1000/72=14) inches. For 1000 pixels at 300 dpi, it will print (1000/300=3.3) inches. But on the screen it will still be 1000 pixels wide and the physical size of the picture on your monitor will only depend only upon your display resolution. If you display is say 1000 x 760 in a 20 in monitor then an image of 1000 pixels wide will be 20 inches wide as your monitor has 1000 pixels that span 20 inches.
Post Reply