Does adding date stamp degrade photo?

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
zBernie
Posts: 4
Joined: 2013-07-26T19:59:34-07:00
Authentication code: 6789

Does adding date stamp degrade photo?

Post by zBernie »

I use the "convert" command in a script to add a subtle date stamp to my .jpg photos taken with my digital camera. Does this result in the loss of much image quality? If so, what is the best way to add a date stamp while minimizing loss of image quality?

${CONVERT} "$i" -font Arial -pointsize 48 -fill lightblue \
-gravity southeast -auto-orient -annotate +80+50 %[exif:DateTimeOriginal] "$i"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Does adding date stamp degrade photo?

Post by fmw42 »

What formats are the input and output images? If JPG, then yes, because it is a lossy compression. Thus each time it is opened and saved it will lose some quality. If non-lossy compression is used in other formats (TIFF, PNG), then no as long as you keep the result as 32-bit or 24-bit color and not lowered to 8-bit color. If you start with 8-bit color and save as 8-bit color, there could be some changes due to the colormap changing to include the color of the timestamp text and any antialiasing used.

see more about file formats at http://www.imagemagick.org/Usage/formats/
zBernie
Posts: 4
Joined: 2013-07-26T19:59:34-07:00
Authentication code: 6789

Re: Does adding date stamp degrade photo?

Post by zBernie »

fmw42 wrote:What formats are the input and output images? If JPG, then yes, because it is a lossy compression. Thus each time it is opened and saved it will lose some quality. If non-lossy compression is used in other formats (TIFF, PNG), then no as long as you keep the result as 32-bit or 24-bit color and not lowered to 8-bit color. If you start with 8-bit color and save as 8-bit color, there could be some changes due to the colormap changing to include the color of the timestamp text and any antialiasing used.

see more about file formats at http://www.imagemagick.org/Usage/formats/

----------

The images are .jpg, taken either with my iPhone 4s 8 MP camera. How much image quality is lost? Is it actually noticeable? Can you recommend a way to minimize the loss of quality?

I need my date stamps on the photos!

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

Re: Does adding date stamp degrade photo?

Post by fmw42 »

The images are .jpg, taken either with my iPhone 4s 8 MP camera. How much image quality is lost? Is it actually noticeable? Can you recommend a way to minimize the loss of quality?

I need my date stamps on the photos!
I cannot say what is or is not visible regarding quality with a read and write of the image? That is subjective.

If you add -quality 100 before writing, it will be the best you can do with saving again to JPG, but it will increase the file size. Alternately, save the result to 24-bit PNG. But again that will increase the file size.

Perhaps one of the photography experts can give you more feedback or other options.

I would not avoid your time stamp if that is important, especially if you see no visible loss in quality.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Does adding date stamp degrade photo?

Post by fmw42 »

You can get some idea about the loss by just reading and writing the original JPG (without doing anything else) and use the compare function to get a measure of the change.

Code: Select all

convert image.jpg image_copy.jpg

or

convert image.jpg -density 100 image_copy.jpg

Then

compare -metric rmse image.jpg image_copy.jpg null:
The resulting value in parenthesis will be the difference in the range from 0 to 1. So if you multiply it by 100, you get a percent change.

see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
http://www.imagemagick.org/Usage/compare/#statistics

Here is a simple example using the IM internal rose: image.

convert rose: rose.jpg
compare -metric rmse rose: rose.jpg null:
1769.16 (0.0269957)

Thus 2.7% difference by taking a 24-bit rose: image and saving to default quality (92) jpg ( with resulting file size of 2.07KB )

convert rose: -quality 100 rose.jpg
c-98-234-221-122:~ fred$ compare -metric rmse rose: rose.jpg null:
189.12 (0.00288578)

Thus at -quality 100, the difference is only 0.29% ( with resulting file size of 6.46KB )


See
http://www.imagemagick.org/script/comma ... hp#quality
zBernie
Posts: 4
Joined: 2013-07-26T19:59:34-07:00
Authentication code: 6789

Re: Does adding date stamp degrade photo?

Post by zBernie »

fmw42 wrote:You can get some idea about the loss by just reading and writing the original JPG (without doing anything else) and use the compare function to get a measure of the change.

Code: Select all

convert image.jpg image_copy.jpg

or

convert image.jpg -density 100 image_copy.jpg

Then

compare -metric rmse image.jpg image_copy.jpg null:
The resulting value in parenthesis will be the difference in the range from 0 to 1. So if you multiply it by 100, you get a percent change.

see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
http://www.imagemagick.org/Usage/compare/#statistics

Here is a simple example using the IM internal rose: image.

convert rose: rose.jpg
compare -metric rmse rose: rose.jpg null:
1769.16 (0.0269957)

Thus 2.7% difference by taking a 24-bit rose: image and saving to default quality (92) jpg ( with resulting file size of 2.07KB )

convert rose: -quality 100 rose.jpg
c-98-234-221-122:~ fred$ compare -metric rmse rose: rose.jpg null:
189.12 (0.00288578)

Thus at -quality 100, the difference is only 0.29% ( with resulting file size of 6.46KB )


See
http://www.imagemagick.org/script/comma ... hp#quality
--------------------

Thanks, that's invaluable! I could never visually detect a difference in quality, but being able to calculate the difference is fantastic.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: Does adding date stamp degrade photo?

Post by GreenKoopa »

jpeg compression splits an image into blocks of 8x8 pixels (a simplification which ignores chroma downsampling). The "best way to add a date stamp while minimizing loss of image quality" is to only recompress the blocks which were modified. ImageMagick, like most every image editor, lacks this ability. Such jpeg specific tools do exist. For most people it isn't worth the effort to avoid a slight loss of quality and increase in file size.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Does adding date stamp degrade photo?

Post by snibgo »

A few rules of thumb:

1. Some cameras have a facility to print the date on the image, when the photo is taken. That would probably give the best result.

2. I don't work from jpeg sources if something better is available. This probably isn't a choice for you.

3. I generally (but not always) can't see a difference when the RMSE is less than 1%.

4. You might get better results by doing the processing in IM and saving to a non-lossy format, then using a more specialist tool to convert that to jpeg.
snibgo's IM pages: im.snibgo.com
zBernie
Posts: 4
Joined: 2013-07-26T19:59:34-07:00
Authentication code: 6789

Re: Does adding date stamp degrade photo?

Post by zBernie »

GreenKoopa wrote:jpeg compression splits an image into blocks of 8x8 pixels (a simplification which ignores chroma downsampling). The "best way to add a date stamp while minimizing loss of image quality" is to only recompress the blocks which were modified. ImageMagick, like most every image editor, lacks this ability. Such jpeg specific tools do exist. For most people it isn't worth the effort to avoid a slight loss of quality and increase in file size.

It's good to know that such tools do exist. But as you said, I don't think it's worth the effort. I certainly cannot see the difference either on the computer screen, or printed photos. And now that I know how calculate the quality loss using the IM "compare", I know the difference in my case is normally < 1%.
Post Reply