"convert -strip" modifies the image
"convert -strip" modifies the image
Hi!
From http://bugs.debian.org/391982, we saw that when using "convert -strip image.jpg" we get a recompressed image on the end (even if there is nothing to do).
It would be good if this process could modify the images losslessly, like jpegtran can do ("jpegtran -copy none image.jpg > newimage.jpg" won't recompress the JPEG)
Thank you!
From http://bugs.debian.org/391982, we saw that when using "convert -strip image.jpg" we get a recompressed image on the end (even if there is nothing to do).
It would be good if this process could modify the images losslessly, like jpegtran can do ("jpegtran -copy none image.jpg > newimage.jpg" won't recompress the JPEG)
Thank you!
Re: "convert -strip" modifies the image
We do not anticipate support for lossless transformations from / to JPEG images in ImageMagick anytime soon. Instead use jpegtran as you mentioned.
Re: "convert -strip" modifies the image
Hi magick,
I saw this interesting study done by Stoyan Stefanov showing that jpeg images compressed by imagemagick are 2% smaller on average than performing the same operation with jpegtran, cf.:
http://www.yuiblog.com/blog/2008/12/05/imageopt-4/
Is this due to imagemagick's slightly lossy conversion? Or it is because imagemagick's compression of jpeg images is better than jpegtran's compression?
I saw this interesting study done by Stoyan Stefanov showing that jpeg images compressed by imagemagick are 2% smaller on average than performing the same operation with jpegtran, cf.:
http://www.yuiblog.com/blog/2008/12/05/imageopt-4/
Is this due to imagemagick's slightly lossy conversion? Or it is because imagemagick's compression of jpeg images is better than jpegtran's compression?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: "convert -strip" modifies the image
IM just uses the JPEG library, same as most other Image Processing Packages.
Any reducing in size is probably due to IM not adding more meta-data to the image! Something that other packages seems to like to do, so as to store its own special meta-data actions. Photoshop especially likes to store resolution information in its own profile additions, where IM prefers to use the standard resolution meta-data location.
Any reducing in size is probably due to IM not adding more meta-data to the image! Something that other packages seems to like to do, so as to store its own special meta-data actions. Photoshop especially likes to store resolution information in its own profile additions, where IM prefers to use the standard resolution meta-data location.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: "convert -strip" modifies the image
Hi anthony,
the study was done stripping all meta-data because it says that the following commands were run:
> jpegtran -copy none -optimize source.jpg result.jpg
> jpegtran -copy none -progressive source.jpg result.jpg
Either IM strips meta-data even better or compress data even better. Either way it would be a nice addition having it losslessly.
the study was done stripping all meta-data because it says that the following commands were run:
> jpegtran -copy none -optimize source.jpg result.jpg
> jpegtran -copy none -progressive source.jpg result.jpg
Either IM strips meta-data even better or compress data even better. Either way it would be a nice addition having it losslessly.
Re: "convert -strip" modifies the image
The differences are due to the recompression and not due to metadata.
The IM JPEG decoder estimates the "quality" used to compress the original
image. If the original image was created with IJG software then the estimate
is exact, but if it came from a camera using proprietary quantization tables,
it won't be an exact match, and IM recompresses the image using
quantization tables that best correspond to the estimated quality. This is usually the case.
The IM JPEG decoder estimates the "quality" used to compress the original
image. If the original image was created with IJG software then the estimate
is exact, but if it came from a camera using proprietary quantization tables,
it won't be an exact match, and IM recompresses the image using
quantization tables that best correspond to the estimated quality. This is usually the case.
Re: "convert -strip" modifies the image
Hi glennrp,
Thanks for the explanation.
I have one further question:
Let us suppose that the quantization tables are the same. After decompression, do IM uses the same algorithm as jpegtran to (re)compress image's data or IM algorithm is more powerful and that also contributes to the 2% difference?
Thanks for the explanation.
I have one further question:
Let us suppose that the quantization tables are the same. After decompression, do IM uses the same algorithm as jpegtran to (re)compress image's data or IM algorithm is more powerful and that also contributes to the 2% difference?
Re: "convert -strip" modifies the image
I think jpegtran is part of the IJG distribution and uses the same code for decompressing.
It's simple enough to test: compress a file with IM and then copy it with jpegtran:
repeatedly.
I verified with "identify -verbose" that jpegtran dies not change
the image signature, so there is no lossy transformation happening.
"convert" does change the signature.
It's simple enough to test: compress a file with IM and then copy it with jpegtran:
- [glennrp@studio ~]$ convert logo: -resize 200% logo2x.jpg
[glennrp@studio ~]$ jpegtran logo2x.jpg > logo2xjt.jpg
[glennrp@studio ~]$ convert logo2xjt.jpg logo2xjtim.jpg
[glennrp@studio ~]$ jpegtran logo2xjtim.jpg > logo2xjtimjt.jpg
[glennrp@studio ~]$ ls -l logo2x*
-rw-rw-r-- 1 glennrp glennrp 95601 Jul 23 12:16 logo2x.jpg
-rw-rw-r-- 1 glennrp glennrp 101152 Jul 23 12:17 logo2xjt.jpg
-rw-rw-r-- 1 glennrp glennrp 92011 Jul 23 12:17 logo2xjtim.jpg
-rw-rw-r-- 1 glennrp glennrp 100558 Jul 23 12:21 logo2xjtimjt.jpg
[glennrp@studio ~]$
repeatedly.
I verified with "identify -verbose" that jpegtran dies not change
the image signature, so there is no lossy transformation happening.
"convert" does change the signature.
Re: "convert -strip" modifies the image
what type of metadata -strip removes?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: "convert -strip" modifies the image
Pretty much all non-pixel data including EXIF, clip paths, TIFF tags and profiles.Vanns wrote:what type of metadata -strip removes?
See also http://www.imagemagick.org/script/comma ... .php#strip
Re: "convert -strip" modifies the image
Will it remove copyright information also?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: "convert -strip" modifies the image
Yes, I believe so, if it is in a meta-data field, but not if the copyright is imbedded in the image pixel data.
Re: "convert -strip" modifies the image
How to prevent it from doing so? Because I want copyright information after stripping. Is there anyway to do that?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: "convert -strip" modifies the image
Copy the information before stripping and then put it back afterwards.
You can extract data such as copyright from your file and put it into a string variable using string formats
Unix syntax:
See
http://www.imagemagick.org/script/escape.php
http://www.imagemagick.org/Usage/windows/
You can extract data such as copyright from your file and put it into a string variable using string formats
Unix syntax:
Code: Select all
copyrightinfo=$(convert yourimage -format "%[copyright]" info:)
Code: Select all
convert yourimage -strip <some processing> -set copyright "$copyrightinfo" yourresult
http://www.imagemagick.org/script/escape.php
http://www.imagemagick.org/Usage/windows/
Re: "convert -strip" modifies the image
Can you help with linux syntax?
Thanks
Thanks