[magick-users] Re: Trouble converting 300dpi jpeg to 72dpi jpeg with same size

Michał Skalski mskalski at enigma.com.pl
Tue Nov 13 06:07:11 PST 2007


I tried (on Win2k, Version: ImageMagick 6.2.2 05/04/05 Q8 
http://www.imagemagick.org)

convert 32.jpg -density 72x72 32-2.jpg

and this does what you want (I checked in properties of file in Windows 
Explorer)

Note, that dpi is only a hint for printing software how many pixels it 
should 'stretch' on one inch on a sheet of paper and is written to 
header of JPEG file - it doesn't have any special meaning (or it should 
not have) for normal raster image processing. If you only want to write 
data do header data, you can try other software for processing EXIF data 
in JPEG files, but for me ImageMagick sets this density accordingly.

Check excellent site of Anthony: http://www.imagemagick.org/Usage - I 
think I saw something about density on this site.

Below is summary of files I converted (note Resolution)
File 32.jpg is original one, without saved any density information.
Files 32-1.jpg and 32-2.jpg are almost binary identical except for four 
bytes where resolution is written.

c:\>convert 32.jpg -density 300x300 32-1.jpg
c:\>convert 32.jpg -density 72x72 32-2.jpg

c:\>identify -verbose 32.jpg
32.jpg JPEG 348x498 DirectClass 24kb 0.060u 0:01
Image: 32.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Geometry: 348x498
  Class: DirectClass
  Type: TrueColor
  Endianess: Undefined
  Colorspace: RGB
  Channel depth:
    Red: 8-bits
    Green: 8-bits
    Blue: 8-bits
  Channel statistics:
    Red:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 146.259 (0.573566)
      Standard deviation: 84.3146 (0.330646)
    Green:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 156.33 (0.61306)
      Standard deviation: 86.979 (0.341094)
    Blue:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 155.334 (0.609152)
      Standard deviation: 93.7502 (0.367648)
  Colors: 67613
  Rendering-intent: Undefined
  Resolution: 72x72
  Units: Undefined
  Filesize: 24kb
  Interlace: None
  Background Color: white
  Border Color: #DFDFDF
  Matte Color: grey74
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 50
  Orientation: Undefined
  JPEG-Colorspace: 2
  JPEG-Sampling-factors: 2x2,1x1,1x1
  Signature: 
d44cdde450ead13fd0844ac92ee82c9c02539a891e85a3fcb0ddc06fb80eebe1
  Tainted: False
  Version: ImageMagick 6.2.2 05/04/05 Q8 http://www.imagemagick.org

c:\>identify -verbose 32-1.jpg
32-1.jpg JPEG 348x498 DirectClass 24kb 0.040u 0:01
Image: 32-1.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Geometry: 348x498
  Class: DirectClass
  Type: TrueColor
  Endianess: Undefined
  Colorspace: RGB
  Channel depth:
    Red: 8-bits
    Green: 8-bits
    Blue: 8-bits
  Channel statistics:
    Red:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 146.178 (0.573249)
      Standard deviation: 84.2115 (0.330241)
    Green:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 156.308 (0.612974)
      Standard deviation: 86.8731 (0.340679)
    Blue:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 155.215 (0.608686)
      Standard deviation: 93.5585 (0.366896)
  Colors: 68074
  Rendering-intent: Undefined
  Resolution: 300x300
  Units: PixelsPerInch
  Filesize: 24kb
  Interlace: None
  Background Color: white
  Border Color: #DFDFDF
  Matte Color: grey74
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 50
  Orientation: Undefined
  JPEG-Colorspace: 2
  JPEG-Sampling-factors: 2x2,1x1,1x1
  Signature: 
d1641c9ce7e06436e7d8e686a12c3565d1754194b7e2f73adb8febc730dfe2c7
  Tainted: False
  Version: ImageMagick 6.2.2 05/04/05 Q8 http://www.imagemagick.org

c:\>identify -verbose 32-2.jpg
32-2.jpg JPEG 348x498 DirectClass 24kb 0.050u 0:01
Image: 32-2.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Geometry: 348x498
  Class: DirectClass
  Type: TrueColor
  Endianess: Undefined
  Colorspace: RGB
  Channel depth:
    Red: 8-bits
    Green: 8-bits
    Blue: 8-bits
  Channel statistics:
    Red:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 146.178 (0.573249)
      Standard deviation: 84.2115 (0.330241)
    Green:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 156.308 (0.612974)
      Standard deviation: 86.8731 (0.340679)
    Blue:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 155.215 (0.608686)
      Standard deviation: 93.5585 (0.366896)
  Colors: 68074
  Rendering-intent: Undefined
  Resolution: 72x72
  Units: PixelsPerInch
  Filesize: 24kb
  Interlace: None
  Background Color: white
  Border Color: #DFDFDF
  Matte Color: grey74
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 50
  Orientation: Undefined
  JPEG-Colorspace: 2
  JPEG-Sampling-factors: 2x2,1x1,1x1
  Signature: 
d1641c9ce7e06436e7d8e686a12c3565d1754194b7e2f73adb8febc730dfe2c7
  Tainted: False
  Version: ImageMagick 6.2.2 05/04/05 Q8 http://www.imagemagick.org


Nicolas Dhomont pisze:
> Thanks for your answer Michal.
>
> I tried :
>
> convert -units PixelsPerInch fromFile -density 72x72 toFile
>
> But 'toFile' is still in 300dpi. 'toFile' file size is even more 
> bigger than 'fromFile' file size. lol
>
> Nicolas
>
> Michał Skalski a écrit :
>> Try -density option instead of -resample
>>
>> Michał
>>
>> Nicolas Dhomont pisze:
>>> Hello
>>>
>>>
>>> I'm trying to convert 300dpi CYMK jpeg to 72dpi RGB jpeg
>>>
>>> I already manage to convert from CYMK to RGB by doing the following :
>>>
>>> convert fromFile -antialias -colorspace RGB toFile
>>>
>>> I'm now trying to convert from 300 dpi to 72dpi with the following :
>>>
>>> convert -units PixelsPerInch fromFile -colorspace RGB -antialias 
>>> -resample 72x72 toFile
>>>
>>> Size of toFile is reduced by a 4,16 ratio (= 300 / 72) but still in 
>>> 300 dpi. (It means that if fromFile is 2.66inch wide, toFile is 
>>> 2.08inch wide for exemple). But I want exactly the opposite : a file 
>>> in 72 dpi with same size.
>>> I've also played with the -density option unsuccessfully.
>>>
>>> As converting is quite simple with photoshop, I guess convert can do 
>>> same but I can't find out how.
>>>
>>>
>>>
>>> Any help would be highly appreciated
>>>
>>> Nicolas
> _______________________________________________
> Magick-users mailing list
> Magick-users at imagemagick.org
> http://studio.imagemagick.org/mailman/listinfo/magick-users
>



More information about the Magick-users mailing list