CS494 Lecture Notes - Some Photo Editing Tips with Gimp and Convert
- James S. Plank
- Directory: /home/plank/cs494/Notes/Gimp
- Original notes: September, 2018
- Most recent modification: November, 2020
Imagemagick's Convert and Gimp
These are two free programs that are pretty much all you need to do a lot of powerful
photo editing. If nothing else, convert lets you convert between JPG, PNG, TIFF,
PDF and EPS. But it does a lot more -- I'll give you an example at the end of these notes.
Brightening a Dark Photo
The most common mistake that automatic cameras make is metering. Sometimes it's not the
camera's fault (like when you take a selfie in front of a window on a bright day). But
a lot of times the camera will meter for the overall lighting, which will leave the subject
dark. Or, it will simply be too dark, and the camera will take a dark picture.
So, it's a good to know how to brighten a photo. Here's what I do.
Here's an example -- this is a picture that my daughter-in-law took with her iPhone of
my granddaughter at a UT game. It is dark and drab, but it is a nice picture.
Open it up in Gimp, and do the following three steps. These will not alter the picture:
- Duplicate the layer, either with Shift-Command-D (I'm doing this on a Mac), or going to the "Layer" menu and selecting "Duplicate Layer".
- Next, you want to bring up the "Add a Layer Mask" dialog. You can do that by typing "M", or
going to the "Layer" menu, then the "Mask" submenu, and then "Add Layer Mask."
- In the "Add Layer Mask" menu, click on two button/boxes:
- Grayscale copy of layer
- Invert mask
And then "Add".
- Pull up the Layers window -- I do that with Command-L, and I'm not finding it in the menu.
Sorry.
The layer window will show two layers -- the original one on the bottom, and the duplicate
layer with the mask on top of it:
You are going to mess with two things on this window -- the "Mode" and the "Opacity".
Change the mode to "Screen". What that does is blend the original with the mask by sampling.
It brightens the photo by brightening the darks a lot and the lights a little. The picture
is already getting better:
You mess with the opacity value to strengthen or reduce the effect. I'm not going to do
it here. However, I am going to mess with the photo some more, because I'd like some more
"depth" in the picture, and I want those baloons to be brighter.
First, I'm going to duplicate the layer again (Shift-Command-D), which duplicates the mask &
screen, brightening it again. I do it one more time. It's a bit overdone right now,
and it feels pretty flat. Here are the two brightens:
Now I merge the layers down to one with Command-M (Image menu, merge visible layers), then
"Merge" on the dialog box. And I bring up the curves tool (Colors menu - Curves. For me, I
can just press "C", but I think I changed that from the defaults). Here's a screen shot:
What I like to do is bump up the contrast, by pulling the curve down at the bottom left:
Then I pull the curve back at the middle, to push the mid-tones and highlights back to what
they were:
You can get some really nice looking pictures from dark photos with this technique.
With this picture, I also went to the Hue-Saturation tool and bumped up the saturation to "50",
so that the balloons would be better. This gave the baby some rosier skin color:
Ever the twiddler, I went back to curves and gave her some more contrast again -- the final
picture:
When you're feeling lazy, you can simply use the curve tool
It's easy to brighten simply with the curve tool by pushing up the highlights (and here,
keeping the low values down). This is
on the original picture:
It works, but I don't like it as much as using the mask/screen above, because it blows out
the high pixel values. For example, there's no sky above. Sometimes, though, you want
contrasty pictures.
The curve tool can resurrect pictures from darkness. For example, on this one, the flash
didn't fire, but I am still able to get something from it. The middle picture was just with the
curve tool. Then in the right one, I desaturated it and messed with the curves.
Or you can use "Sigmoidal-Contrast" with imagemagick
The -sigmoidal-contrast command in the convert program also gives you
a quick-and-dirty way to brighten pictures. To brighten P01.jpg a little, here's
the command:
UNIX> convert P01.jpg -sigmoidal-contrast 1,0 tmp1.jpg
Increase the "1" to get more brightening. Below, I show values from 1 to 5:
A few more hints in no particular order
- Brightening a dark picture works much better than trying to fix an overexposed picture.
That's because all of the overexposed pixels are sitting there with values of 255 -- there's
no information in them. On the flip side, there's lots of information in the dark pixels,
which aren't 0, but just have low values.
- The best thing to attempt with an overexposed picture is to bring up the curve tool, and then
pull down that curve to try to get some darker pixels.
- Experiment with using "dodge" in addition to "screen." Sometimes I'll make the last layer
a "dodge" layer with 20% opacity -- it bumps up the color, but also flattens the picture more
than "screen".
- When you can't get the color right, desaturate it and turn it into black & white. A corollary
of this is when you see a black & white picture, the chances are that the photographer messed up
the metering, and the only fix was taking out the color. Then, the photographer will comment on
how much more "emotional" the black & white picture is. However, you and I will know that he/she
simply messed up the metering....
- On a super-sunny day, consider taking some pictures in the shade and brightening them with
gimp. That will often be far superior to those totally unflattering,
mega-contrasty pictures that you get in direct sunlight.
- You can flatten out those mega-contrasty pictures with the screen layer as above. You'll
have to mess more with the overall curves afterward.
- This has nothing to do with gimp, but when you're using artificial lighting, try to get it
to not come straight from the camera.
- The "Intelligent Scissors" ("I") tool in Gimp is stellar. I like it better than Photoshop's
"magic wand."
- If you want to put transparency into a picture, do "Layers" -> "Transparency" -> "Add Alpha Channel." Then if you want to isolate part of a picture and strip out everything else, then
select what you want to isolate (with the intelligent scissors), invert the selection, and then
do "Edit" -> "Clear". You need to save the photo in a format that supports transparency (like PNG).
These pictures work really well in your powerpoint/libreoffice presentations.
Convert
I don't have time to tell you about convert. It's a great tool for composing photos.
Here's an example of using convert to make a labeled collage for a photo frame. Obviously,
I wrote a program to generate the convert command, but I'm hoping this shows you how powerful
convert is (BTW, if you want the program, let me know -- I'm not possessive):
UNIX> ls -l Fish-*.JPG
-rw-r--r-- 1 plank staff 2152216 Sep 28 11:04 Fish-Alex.JPG
-rw-r--r-- 1 plank staff 8904152 Sep 28 11:04 Fish-Chris.JPG
-rw-r--r--@ 1 plank staff 1009049 Sep 28 11:04 Fish-JCJ.JPG
-rw-r--r--@ 1 plank staff 1887030 Sep 28 11:04 Fish-Jeff-Alex.JPG
-rw-r--r-- 1 plank staff 6268208 Sep 28 11:04 Fish-Jeff.JPG
-rw-r--r-- 1 plank staff 5087292 Sep 28 11:04 Fish-John.JPG
-rw-r--r--@ 1 plank staff 3429525 Sep 28 11:04 Fish-Thor.JPG
-rw-r--r--@ 1 plank staff 3089771 Sep 28 11:04 Fish-Tolu.JPG
-rw-r--r--@ 1 plank staff 5045460 Sep 28 11:04 Fish-Tom.JPG
UNIX> cat fish.sh
convert -size 2600x1664 xc:white \
Fish-Tolu.JPG -geometry 655x797+15+15 -composite\
Fish-Jeff-Alex.JPG -geometry 820x797+680+15 -composite\
Fish-Tom.JPG -geometry 536x706+1510+15 -composite\
\( Fish-Alex.JPG -scale 530 -crop 529x706+0+0 \) -geometry 529x706+2056+15 -composite\
\( Fish-JCJ.JPG -scale 449 -crop 448x823+0+0 \) -geometry 448x823+1510+731 -composite\
Fish-Thor.JPG -geometry 617x823+1968+731 -composite\
Fish-Chris.JPG -geometry 488x732+15+822 -composite\
\( Fish-John.JPG -scale 488 -crop 487x732+0+0 \) -geometry 487x732+513+822 -composite\
Fish-Jeff.JPG -geometry 490x732+1010+822 -composite\
\( -size 2570x85 -background '#0450E9' -fill 'white' -stroke 'none' -gravity Center label:'Triumphantly Displaying our Salmon - Soldotna, AK - July, 2016' \) \
-geometry 2570x85+15+1564 -gravity NorthWest -composite Fish-Collage.jpg
UNIX> sh fish.sh
UNIX>
Converting PDF to JPG
Do:
UNIX> convert -density 300 xxx.pdf -quality 100 xxx.jpg
Trust me on this one.