convert -flop image.jpg image.jpg

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
cmancre

convert -flop image.jpg image.jpg

Post by cmancre »

Hi everyone. I'm new to imagemagick and so far so good... I'm playing around with what could be done by command line and I notice this:
Running the following command convert -flop image.jpg image.jpg , i.e, flopping an image to it self. This actions results in a loss of quality. The floped image starts to look a bit pixelized and stripes.
Is there anything I can do?

Thanks
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Re: convert -flop image.jpg image.jpg

Post by rmagick »

Are you running this command more than once? Keep in mind that JPEG is a lossy format. Each time you modify a JPEG image the image is re-compressed with a resulting loss of quality. After enough recompressions you end up with a bad-looking image. If you need to make several changes to a JPEG image, save the intermediate versions of the image in a non-lossy format such as ImageMagick's MIFF format.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert -flop image.jpg image.jpg

Post by fmw42 »

put the input image before the -flop and also regarding the loss, save the image in non-jpeg format such as png or use -quality 100

convert image.jpg -flop image1.png

or

convert image.jpg -flop -quality 100 image2.jpg
cmancre

Re: convert -flop image.jpg image.jpg

Post by cmancre »

That's because default quality is 80 or something like that.

Thanks a lot
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert -flop image.jpg image.jpg

Post by anthony »

Note that -quality 100 will only slow the loss in a normal JPEG image file format. It will only produce a lossless quality for JPEG2000 image file format.

However cmancre is right in that IM has no real way of determining the original quality (by default) of a input JPEG image. Though it does have a method of making a rough guess at the quality.

Best Ideal is to only use JPEG for the final display image, but keep images in some other loss-less format for later modifications. Better still always start from the source image rather than modify an already modified image.

See IM Examples, Common File Formats, JPEG for more info
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply