1
\$\begingroup\$

I have lots of photos with writing on the back. I've scanned the fronts and backs into jpgs, and now I want to create a single jpg for each front/back pair. The front and back images should go side by side in the new jpg. I'm looking for a way to do this with minimal loss of image quality and without losing the metadata for at least one of the images. I'm running on Windows 10.

MS Paint makes it easy to put the images side by side, but the resulting file is only about 1/3 the sum of the jpg sizes, so I assume I'm losing lots of quality. MS Paint3D's files are even smaller, and, unlike Paint, no metadata is retained.

In addition to standard Windows 10 programs, I have XnView MP, FastStone Image Viewer, and Adobe Bridge. I'm willing to download new software, but I'd prefer not to have to buy something for this hobby project. I'd also prefer to work locally rather than using web-based utilities.

Thanks for any help you can offer.

\$\endgroup\$
4
  • \$\begingroup\$ lossless JPG is a thing, but it's not widely used/supported \$\endgroup\$ Jan 25, 2023 at 1:20
  • \$\begingroup\$ I don't expect lossless (it's jpg), but a way for me to configure the quality to close to 100 would be nice. \$\endgroup\$ Jan 25, 2023 at 1:21
  • 1
    \$\begingroup\$ Why not a lossless format? \$\endgroup\$ Jan 25, 2023 at 1:22
  • \$\begingroup\$ Lossless would be fine, as long as it's a common format and contains metadata. \$\endgroup\$ Jan 25, 2023 at 1:31

2 Answers 2

2
\$\begingroup\$

ImageMagick can do this:

magick front-side.jpg back-side.jpg +append result.jpg

result.jpg contains a copy of the metadata from the first input file (i.e., front-side.jpg).

Regarding the jpg quality, the documentation says:

The default is to use the estimated quality of your input image if it can be determined, otherwise 92. When the quality is greater than 90, then the chroma channels are not downsampled. Use the -sampling-factor option to specify the factors for chroma downsampling.

For maximum quality, specify a quality value of 100:

magick front-side.jpg back-side.jpg -quality 100 +append result.jpg

Jpgs lose quality every time they're saved, so I doubt that a quality value of 100 will avoid any quality degradation compared to the originals, but presumably this is the best you can do.

\$\endgroup\$
2
  • \$\begingroup\$ BTW, +append appends horizontally, -append stacks vertically. \$\endgroup\$
    – ths
    Jan 30, 2023 at 16:50
  • \$\begingroup\$ correction: Jpgs can lose quality every time they're saved, it's not guaranteed. Think of a solid white jpg; doesn't matter how many times you resave or what compression you use; each pixel is literally the exact same no matter what. Even real-world images re-saved at 100% often (usually?) match identically; only in higher compression modes do differences emerge. \$\endgroup\$
    – dandavis
    Feb 2, 2023 at 7:21
1
\$\begingroup\$

There several free image editors out there, such as Gimp, Krita and MyPaint. They are all capable of putting together two images side by side, but the actual actions will all be slightly different. Usually, the metadata of the base image (the one you load first) is kept.

If your images are scans, there is not much metadata. You have the resolution (but this is useful only if you want to print the picture at the very same size), possibly some Exifs (Digitized Date), but way less that with a camera. Otherwise I assume that you have added descriptions or other tags manually? In any case EXIF/XMP/IPTC do not define how to store metadata for several pictures, so you will have to chose. The metadata of the back scan is possibly a bit less important. If this is critical, there are ways to merge the metadata of one picture into the metadata of another (I don't know is the software already exists, but this can be written as a script based on utilities such as ExifTool). A variant of this is to copy the metadata from one of the source images to the composite image (utilities such as ExifTool can do this), so you don't have to worry about metadata support by the image editor.

Decent image editing software lets you set the JPEG encoding parameters. There are two distinct parameters:

  1. Chroma sub-sampling: JPEG considers that our eyes are much more sensitive to luminosity than to color, so your RGB image is decomposed into 3 images: a Luminosity one and two "chroma" ones. The chroma images can have their size reduced (halved or quartered) and this alone can drastically reduce the size of the file (and has minimal visual impact).
  2. Quality: the one everyone knows. Quality in the 90-95 range is usually enough. The real question is the actual quality used by the scanner software if it produces JPEGs.

The small size of your output files is probably more the result of a reduced chroma than of reduced quality, but this is just a guess. The best way to tell what happens to you files is utilities such as ImageMagick's identify.

\$\endgroup\$
4
  • \$\begingroup\$ This is not a useful response. It essentially says, "A decent image editor will let you do this," but I already knew that. I'm looking for a more specific suggestion. However, your mentioning ImageMagick reminded me that I also have that installed, and playing around with it shows that magick file1.jpg file2.jpg +append result.jpg does what I want and yields a file size roughly the sum of the jpgs' file sizes. \$\endgroup\$ Jan 25, 2023 at 4:00
  • \$\begingroup\$ Have you checked that the metadata has been copied over? \$\endgroup\$
    – xenoid
    Jan 25, 2023 at 9:11
  • \$\begingroup\$ Yes, using ImageMagick copies the metadata from the first image file. \$\endgroup\$ Jan 25, 2023 at 16:21
  • \$\begingroup\$ @KnowItAllWannabe if you found a satisfactory solution, you can post it as an answer yourself. \$\endgroup\$
    – ths
    Jan 25, 2023 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.