JPG cropping without compromising quality
Solved
lenainjaune
Posted messages
726
Registration date
Status
Contributor
Last intervention
-
contrariness Posted messages 17905 Registration date Status Member Last intervention -
contrariness Posted messages 17905 Registration date Status Member Last intervention -
Hello everyone,
I have just started the heavy task of scanning paper family photos. I have scanned in JPG format, 2 photos at a time from a scanner, separating them.
I have tried 2 automations to extract the photos:
- Francois Malan's DivideScannedImages plugin: gives few results at a constant threshold (I think it's due to the heterogeneous lighting of my photos), many false positives
- Fred Weinhaus's ImageMagick multicrop script: extracts 95% good images ... without doing anything particular (strangely the erroneous photos had undergone a rotation, whereas they were horizontal)
So I used the IM multicrop script and to extract the failed photos I use TheGimp.
From TheGimp, after exporting to JPG, I noticed that some photos are over 1MB. So I looked closely at the settings:
- Quality: 90%
- Non-progressive (no interlacing)
- Subsampling: 4-2-2 horizontal (the doc gives 2x1,1x1,1x1 - same factor as the original scan)
For example, for a 1.1MB scan:
- IM multicrop: photo1=435KB, photo2=449KB (similar zooms in terms of feeling)
- TheGimp JPG export: photo1=624KB, photo2=1.4MB (> original scan!!!)
I will have plenty of scans to process and I need to solve the problem to lose as little space as possible.
From TheGimp, what settings should I apply to have the same quality as the original scan without "inflating" the exported file unnecessarily?
Environment:
- ImageMagick v6.6.9
- Gimp v2.8.20
If anyone can shed light on the subject, it would be really cool :)
Best regards,
lnj
Configuration: Ubuntu 12.04
I have questions for all your answers. (Woody Allen)
I have just started the heavy task of scanning paper family photos. I have scanned in JPG format, 2 photos at a time from a scanner, separating them.
I have tried 2 automations to extract the photos:
- Francois Malan's DivideScannedImages plugin: gives few results at a constant threshold (I think it's due to the heterogeneous lighting of my photos), many false positives
- Fred Weinhaus's ImageMagick multicrop script: extracts 95% good images ... without doing anything particular (strangely the erroneous photos had undergone a rotation, whereas they were horizontal)
So I used the IM multicrop script and to extract the failed photos I use TheGimp.
From TheGimp, after exporting to JPG, I noticed that some photos are over 1MB. So I looked closely at the settings:
- Quality: 90%
- Non-progressive (no interlacing)
- Subsampling: 4-2-2 horizontal (the doc gives 2x1,1x1,1x1 - same factor as the original scan)
For example, for a 1.1MB scan:
- IM multicrop: photo1=435KB, photo2=449KB (similar zooms in terms of feeling)
- TheGimp JPG export: photo1=624KB, photo2=1.4MB (> original scan!!!)
I will have plenty of scans to process and I need to solve the problem to lose as little space as possible.
From TheGimp, what settings should I apply to have the same quality as the original scan without "inflating" the exported file unnecessarily?
Environment:
- ImageMagick v6.6.9
- Gimp v2.8.20
If anyone can shed light on the subject, it would be really cool :)
Best regards,
lnj
Configuration: Ubuntu 12.04
I have questions for all your answers. (Woody Allen)
6 answers
-
Hi
We scan in tif, make the modifications, and save (only once) in jpeg
--
-
-
Re-
So I understood that to do it correctly I should have scanned in TIFF format which is lossless compressed. I didn't know that the TIFF format served this purpose but I'm not sure if the RICOH multifunction device allowed it.
I would like to know if I understand well what happens in the processing chain.
According to what the identify tool from IM returned (see the response I made to contrariness), the scanner produced compressed files at 51% (=> losses = 51%?) and since I export from TheGimp with a compression level of 90% (default value), the files are huge.
If I understand correctly:
- the scanner captured and created a raw image and converted it to JPG with a quality of 51% (therefore there are many losses - since the JPEG format is not lossless)
- when I open the image, it decompresses the image to 51%, we get an image of similar size to the raw image created by the scanner (a kind of bitmap image I think), but obviously without all the details of the original raw image (what the compression has lost)
- I do my cropping and I want to export, in the best case I keep the same level of details when saving, but I think that recompresing at 51% gives "approximately" the same level of detail as that produced by the scanner (basically we don't have "too" many additional losses compared to the first compression), but it is useless to compress beyond 51% then
Would that be it?
-
-
In JPG compression, it's not so much the size of the photo that influences the weight, but its content... (apart from the compression rate, of course)
The more an image has different color areas, the more the weight will be significant (for the same image size).
In the export from Gimp, did you cancel after isolating the first image to make the second, or did you start again from the original image to crop it?
Scanning multiple images at the same time is indeed faster, but it comes at the expense of quality. The scanner will average the colors, which may favor some over others... (unless you can disable the automatic settings and have a neutral manual mode).-
Hello,
In the export I did: 1) open the image, 2) delimit the 1st photo with a selection, 3) copy, 4) Paste as new image, 5) Export JPG of this new image, 6) close the image, 7) delimit the 2nd photo, ... but I did not go through Undo. Why would I do that???
Indeed, I am aware that it's not a good idea to scan two at a time, but I was pressed for time and it simplified the maneuvers. Additionally, I scanned at a resolution of 600x600 px, which gives an acceptable level of detail (at least for my eyes).
Moreover, as kaumune pointed out to me, I did not, in principle, apply the correct method to be clean (TIFF ->....-> JPG). I don't have the exact model of the scanner in mind (a multifunction RICOH) but apparently, after looking at different models online, the specifications indicate that PDF, JPG, and TIFF formats are supported. So I will try to apply this for future scans.
What I don't understand is that IM does not inflate the "cropped" JPG files like TheGimp does. Hence my question...
[edit]I meant the scan resolution is 600x600 dpi[/edit] -
I wonder if there might be a bug in Gimp that keeps the cache of the first image when adding it during the second copy/paste.
Try closing the original image before performing the action.
I don't use Gimp, but can't you crop the image before saving it instead of copying/pasting a selection?
Another thing... make sure that your two images, which are practically the same size, are at the same resolution. -
I tried closing the image (by creating a project file with guides to have the same bases), using the crop tool then the select/copy/paste tool => the exports are about the same size as those I got with my initial method
I don't think there is a bug like that; I would lean more towards my unfamiliarity with the software.
Now, with a concrete example:
My scan is 1.2MB, the IM multicrop script extracts 2 photos P1: 543KB and P2: 492KB, but P2 not being straight, I open the scan, crop and export (quality: 90% I remind you) => P2': 1.3MB (so about 3xP2)
=> P1 + P2 ~= 1.2MB but P2' ~= 3xP2 => WTF!!!!
Looking at the multicrop help, there is no notion of quality => IM knows how to crop without affecting quality but TheGimp???
-----
I don't understand the last remark:
Another thing.. check that your 2 images that are practically the same size are indeed at the same resolution.
Copying/pasting in TheGimp does not change the resolution.
The photos on each scan have the same resolution 600x600 dpi (global setting) but do not necessarily have the same dimensions (width x height).
Could you clarify which images you are talking about (I'm starting to feel like my brain is turning to mush :) )?
-
-
I don't know Gimp, but if I compare it to Photoshop, copying/pasting into a new document takes the resolution and size of the image in the clipboard. However, pasting into an already opened document takes the resolution of that document (which can be different from what you're pasting).
If an image modified in Gimp increases in size after modification, it means there is one or more settings that are modifying the image.
In the settings, you have resolution, compression, bits per color, and color space...
Open your two images, the one from the script and the one after modification in Gimp, and check the image information... there should likely be some differences.-
I had done it using TheGimp but I didn't see anything particularly significant.
So, I searched and found the identify tool from IM to get more information about an image (identify -verbose). Here is the result of the diff between the info from the automatic cropping by script and that from the export of TheGimp.
At the end:< Quality: 51
---
> Quality: 90
indicates that the photo cropped by script would have a quality of 51% and that the one exported from TheGimp would indeed have the quality that I set at the time of export, namely 90%.
Upon further investigation, I noticed that the scan info also indicates a quality of 51%. This would mean that the scanner produces JPG scans with a quality of 51% (which seems very low to me).
So, I tested an export of the photo with a quality of 51. The image is 505KB
I compared a zoom of the photo on the scan to a zoom of the exported one; they seem to be roughly identical, at least in terms of feel.
However, in the TheGimp documentation, it is indicated that this compression factor does not necessarily mean the same thing between one application and another.
So it seems a bit more relevant now!
-
-
In JPG compression, there are 2 parameters that affect the file itself.
- The compression rate (which influences the image quality)
- The compression ratio, which is the % obtained based on the data contained in the image. For example, if you have an image composed of a black rectangle on a white surface, you could achieve a ratio of 2 or 3% of the original file size... Because compression will occur only on 2 colors and not on a range of gray tones or colors.-
-
Good evening Contrariness,
I don't know Gimp, but if I compare it to Photoshop, Copy/Paste in a new document takes the resolution and size of the image in the clipboard. However, pasting into an already opened document takes the resolution of that document (which may be different from the one being pasted).
Your comparison is good; both work the same way, at least at this level...
Have a great evening and a good day. ;)
Luke.
-
-
So the problem is solved!
Thanks to kaumune and contrariness for your help ;)
The preferred method is as kaumune indicates:
- if possible, scan in TIFF format (large, lossless format)
- make all necessary adjustments
- export in JPEG format (lighter, lossy)
For those who made the mistake like I did of scanning in JPEG format, here
is what happens if I understood correctly (the drawing is an original and personal creation).
Attention:
1) this is only a VERY simplified view
2) I am not an expert on the subject (far from it), this is how I perceived it through several readings and how I understand it, but I could be wrong! So don't take this as "ironclad," stay vigilant and critical!
The question is to know the quality that the scanner used to produce the JPEG file.
You can get it using the identify command from ImageMagick (open-source software). Here is the identify command (on Linux):$ identify -verbose mon_scan.jpg | grep Quality
=> Quality: 51
In The GIMP, to export as JPEG, there are 3 settings to apply to lose the least amount of information possible: quality, whether the image display is interlaced = progressive (speeds up image loading on a web page), and subsampling. Here is the export JPEG window for The GIMP v2.8.20):
You can obtain these settings using the identify command:$ identify -verbose mon_scan.jpg | egrep "Interlace:|Quality:|jpeg:sampling-factor:"
=> Interlace: None
=> Quality: 51
=> jpeg:sampling-factor: 2x1,1x1,1x1
Note 1: in the The GIMP documentation, it is specified that quality is a factor that is not the same from one software to another
Note 2: still in the documentation, 2x1,1x1,1x1 is presented either as 4:2:2 horizontal or 4:2:2 vertical; I tested horizontal and it works well for me
In the end, you get an image file size in relation to that of the original scan.
My recent little experience showed me that this method produced acceptable results (at least for me). It's up to you to see if it suits you!
There you go :)
I have questions for all your answers. (Woody Allen)-
I was able to access the scanner again.
Often, the TIFF format is only possible for black and white images. Unfortunately, this is the case for this scanner (RICOH SP C250SF). The documentation is clear on the subject (http://support.ricoh.com/bb_v1oi/html/oi/re/model/spc250sf/spc250sfen.htm
So in any case, I selected the best quality that this device could deliver (JPEG 600x600 dpi).
-
-
Do you use the Twain driver to scan your documents?
In that case, you should have the choice of resolution and file format...