editing multiple photos in the same way

7 respostas [Última entrada]
muhammed
Desconectado
Joined: 04/13/2013

I have 25 colour photographs, 5 megapixels each, in a folder on my computer. I would like to edit each in the same way: scale down to 1000px * 1333px, and apply Gimp's "photocopy" filter. Can I make Gimp edit each photo in this way automatically -- it would be time consuming to do each manually.

hack and hack
Desconectado
Joined: 04/02/2015

Try ImageMagik, it can be used with Gimp I believe.

I've had good experience using the (marvelous) automation on Photoshop (just record a sequence of actions, and apply the sequence on a whole folder).

I've never tried ImageMagik yet, but I suspect it isn't as easy to use. But it seems powerful enough.

EDIT:
Just found this: http://www.alessandrofrancesconi.it/projects/bimp/

There's also this one, available from the plugin registery (I think it's an extra download from the repo).

It will work for your needs though. Not sure about scaling, but it can be done in David's batch processor.

EDIT2:
I might have worded that badly, so:
I'm certainly not suggesting Photoshop as a solution, just using it to compare functionalities..
I quickly tried David's batch processor from the plugin registery, it's OK, but limited (plus it seemed buggy when I tried to rotate images, which was only possible about 90° each time, nothing in between).

I also tried G'MIC (from inside GIMP), and while it has some nice amount of control regarding colors, there's not much in terms of precises rotation and such. I might try BIMP, but I doubt it's much better. Oh well.

Magic Banana

I am a member!

I am a translator!

Desconectado
Joined: 07/24/2010

G'MIC probably is a solution by itself (i.e., without using GIMP): http://gmic.eu

It is in Trisquel's repository.

danish
Desconectado
Joined: 02/19/2017

I don't know what the "photocopy" filter actually does, but, you can resize the images with mogrify -resize.

I don't know how to "nobump" here, sorry.

ADFENO
Desconectado
Joined: 12/31/2012

As Magic Banana pointed out, G'MIC might be a good idea to try, also,
ImageMagic is also a great tool for the job.

Note 1: The example given in the end of this comment will replace the
existing images, so make sure to have backups. I could make a more
elaborated example, at the cost of losing easy understanding.

Note 2: My copy of ImageMagick came from Guix package manager, not from
Trisquel 7's repositories, so there might be differences in the
result. Specially because I was forced to upgrade my ImageMagick because
I needed to work with .jpg images which had embeded color profiles.

Note 3: Please replace the lines starting with "/home/adfeno" to the
full/absolute path to the images that you want to edit. This can be done
by selecting all of then in file manager (default for Trisquel is
Nautilus), copying them, pasting in a text editor, and this should give
the paths you want to copy again and paste in the area I just described.

I'll first describe what the `convert` command options do, and then I'll
give you the actual script.

Description:

`-auto-orient` attempts to read EXIF orientation tag from the image
file, and respects it. The resulting image will not have such EXIF tag,
but will still be corrected. This avoids having images in the wrong
orientation.

`-colorspace "Gray"` converts from the image's color space to a generic
grayscale color space. Note that, if the input image depends on a more
complex color space (like the CMYK madness, for which even conversion
between the exact CMYK profile results in distortion), and if you want
the resulting image to use RGB color (the color used by the
monitor/display you are using to read this now), you must place
`-profile [Path to desired RGB color profile file]` before `-colorspace`
line. For the sake of completeness, in the case of Trisquel 7, the path
for the color profile of your current monitor/display can be obtained
using the following command:

$ colormgr get-devices-by-kind "display"

And to check if the images have embeded color profiles (and which color
space/standard they represent), use:

$ identify -verbose "[Path to image file]"

To find the color space, look for the topmost "Colorspace" line. To find
out if the color profiles are embeded, look for the topmost "Profiles"
line (this line has others inside). If the color space is CMYK, then the
profiles *must* exist, otherwise the photocopy effect might produce
non-grayscale or bad results.

Now, continuing with the main explaination:

`+clone` clones the last generated image (the one resuting from setting
the image as grayscale only) to the set of current operations (which are
limited between "\(" and "\)").

`-blur "0x2"` blurs the image slightly. Particularly, I find this value
to produce a result more closer to a photocopy than the one produced by
the values suggested by my copy of GIMP.

`+swap` swaps the the last two images in the sequence (this should put
the grayscale image behind the original one).

`-compose "DivideDst"` uses the mathematical compose method called
"DivideDst" which is, like all mathematical compose methods, greyscale,
and simply attempts to divide the uppermost image in the sequence by the
previous image in the sequence. This means, for example, that: If the
grayscale (previous image) has a color understood to be similar to zero,
that part of the uppoermost image is ignored. With older versions of
ImageMagick, the "DivideDst" is called "divide".

`-composite` actually generates the image that resulted from all
operations so far. This makes a new image available in the sequence.

`-linear-stretch "5%x0%"` does some color stretches. Particularly, I
find this value to produce a result more closer to a photocopy than the
one produced by the values suggested by my copy of GIMP.

`-scale [Geometry]` scales the topmost image (no enclosing "\(" or
"\)") but *keeps* aspect ratio (avoids "fat" or "tin" effects on
images). If you do want to force the geometry of 1000x1333, then use
"1000x1333!" instead (notice the exclamation mark).

Actual script:

while read -r each_original_image; do
convert "$each_original_image" \
-auto-orient \
-colorspace "Gray" \
\( +clone -blur "0x2" \) \
+swap \
-compose "DivideDst" \
-composite \
-linear-stretch "5%x0%" \
-scale "1000x1333" \
"${each_original_image}"
done <

Geshmy
Desconectado
Joined: 04/23/2015

Adfeno, Thanks for this, I adventured into ImageMagick for the first time. Fun.

Re..."Note 3: Please replace the lines starting with "/home/adfeno" to the
full/absolute path to the images that you want to edit. This can be done
by selecting all of then in file manager (default for Trisquel is
Nautilus), copying them, pasting in a text editor, and this should give
the paths you want to copy again and paste in the area I just described."

Where exactly? I did select all - copy - paste into text editor but what next?

I was not able to get a while read -r loop to work so I ended up replacing the variable "$each_original_image" with an actual image name (path I suppose, but I ran the command from the same folder - convert testImage.jpg -scale "854x1280" "{testImage.jpg}").

And does the final < in your script belong there?

Magic Banana

I am a member!

I am a translator!

Desconectado
Joined: 07/24/2010

A file listing the paths to the pictures should be written after the "<". If one single directory only contains the pictures in question then you can open a terminal in that directory and write "for each_original_image in *; do" instead of the first line in ADFENO's script. You should then also remove the final "<".

Again, G'MIC is ImageMagick on steroids. Certainly the most versatile tool when it comes to applying filters on images. See for yourself: https://jpfleury.github.io/gfo-demos/ (click on any link below any picture to literally see hundreds of modifications applied to it; and click on the down arrow in a back box below any modification to see what option was used to obtain it).

Geshmy
Desconectado
Joined: 04/23/2015

Thanks Magic for the clarification, I understand the < now

I also did find gmic and the gimp-gmic plugin in Flidas repository and installed them. Will try that out also. The http://gmic.eu/ website looks very cool.

Gracias :)