Multiple png files to multiple ico files: Strange behavior - windows

There are 2 png images in a directory: a.png and b.png. I'm trying to convert them to a.ico and b.ico with a single command.
Doesn't work as I want, only a.ico is created:
magick.exe *.png -define icon:auto-resize="256,128,96,64,48,32,16" -set filename:f %t %[filename:f].ico
However, the same approach works fine when I convert the images from PNG to JPG:
magick.exe *.png -set filename:f %t %[filename:f].jpg
What's wrong here?

Related

How do I rename images when using mogrify with Image Magick?

I am trying to automate the converting images to specified tif formats. I have it converting just fine, but am also needing to add "_GS" at the end of the file name and before the extension to each file converted. Below is what I have but have had no luck finding a solution to add "_GS" to the file name. Thanks in advance for any help.
for f in "$#"
do
echo "$f"
/usr/local/bin/mogrify -density 300 -resize 1000x1000 -type grayscale -define tiff:endian=msb -compress LZW -format tif "$f" [0]
done
Item 1: With Image Magick, to create a new file instead of overwriting an existing one, use convert, not mogrify (magick convert with newer versions of IM).
Item 2: You can use shell parameter expansion to remove the extension, and then build the new filename from that and the new suffix:
for f in "$#"
do
echo "$f"
/usr/local/bin/convert "$f" -density 300 -resize 1000x1000 -type grayscale \
-define tiff:endian=msb -compress LZW -format tif "${f%.*}_GS.tiff"
done
${variable%pattern} returns the expansion of variable with the shortest match of pattern removed from the end.

Convert entire folder to greyscale using image magick?

I am trying to convert an entire folder to grayscale, using image magick.
convert *.jpg -colorspace Gray -separate -average
is met with this error :
convert: `-average' # error/convert.c/ConvertImageCommand/3290.
What is the correct command for this?
If you have lots of files to process, use mogrify:
magick mogrify -colorspace gray *.jpg
If you have tens of thousands of images and a multi-core CPU, you can get them all done in parallel with GNU Parallel:
parallel -X magick mogrify -colorspace gray ::: *.jpg
Also, the following can be used in a script - for the context menu of file managers like Dolphin, Nautilus, Nemo, Thunar etc:
for filename in "${#}"; do
name="${filename%.*}"
ext="${filename##*.}"
cp "$filename" "$name"-grayscale."$ext"
mogrify -colorspace gray "$name"-grayscale."$ext"
rm "$name"-grayscale."$ext"~
done

copy one picture and paste it on top of the other on terminal

In here I found a piece of code that finds and resizes all images within a folder with applescript
Now I need to apply a stamp to those images one by one. I already have a transparent jpg prepared with the same size and ready to be pasted on all of them.
I just lack the knowledge to do it on terminal so I could mix it with applescript.
Does anyone know how to do this without making a workflow? Because it takes a lot of time and keeps the laptop busy
Updated Again :-)
You can get the height of an image like this:
identify -format "%h" image.jpg
500
and the width like this:
identify -format "%w" image.jpg
800
If you want to find the lesser of the height and the width, and then take 10% of that for your logo size and make it integer, you would do:
identify -format "%[fx:int(0.1*min(h,w))]" image.jpg
50
If you want to put that in a variable, you would do
logosize=$(identify -format "%[fx:int(0.1*min(h,w))]" image.jpg)
echo $logosize
50
You could then use that in the original command below like this:
convert image.jpg -gravity southeast \
\( copyright.png -resize "${logosize}x${logosize} \) \
-composite result.jpg
I suspect you are going to want to run that with the find command, aren't you? :-)
find . -iname \*.jpg -exec bash -c 'echo Processing {};logosize=$(identify -format "%[fx:int(0.1*min(h,w))]" "{}"); echo $logosize;convert "{}" -gravity southeast \( copyright.png -resize "$logosizex$logosize" \) -composite "{}"' \;
Updated Answer
If you want to resize your original image before compositing the logo unchanged on top, use a command like this:
convert image.jpg -resize 2000x1000 -gravity southeast copyright.png -composite result.jpg
If you want to resize the logo before compositing it on top of the unchanged original image, use a command like this:
convert image.jpg -gravity southeast \( copyright.png -resize 700x200! \) -composite result.jpg
Original Answer
I would use ImageMagick. It is extremely powerful and simple to install if you use homebrew. Ask if you don't know how...
Let's assume you have an image called image.jpg and a transparent logo/copyright called copyright.png.
image.jpg
copyright.png
Then the command to do a single image would be:
convert image.jpg copyright.png -composite result.jpg
If your logo/copyright and image are different sizes, and you want to force the logo to, say, the bottom right corner, just set the -gravity accordingly like this:
convert image.jpg -gravity southeast copyright.png -composite result.jpg
If you wanted to do all the JPEGs in the folder, you would need a loop:
#!/bin/bash
shopt -s nullglob
shopt -s nocaseglob
for f in *.jpg; do
convert "$f" copyright.png -composite "$f"
done
By the way, you cannot have a transparent JPEG - that format doesn't support transparency.
If you are really intent on using Applescript - I don't know why anyone would be - you can call the above using do shell script - make the file executable first. Ask if unsure how.
If you want to recurse down into all directories (folders) starting at the one you are currently located in and add the logo/copyright to all images, I would make a copy of them somewhere else first and do a trial run. The command would be:
find . -iname "*.jpg" -exec convert "{}" copyright.png -composite "{}" \;
That says... "find, starting at the current directory (.), disregarding upper/lower case (-iname), all files ending in "JPG", and apply the logo/copyright to them, resaving on top of the original file".
I had same issue years ago, and the only way I found is an Applescript using Photoshop (duplicate layer containing the logo on the photo and flatten file).
the script loops to all file of a folder.
... but you need Photoshop for this script !
I can share that script if it helps

ImageMagik: Blur map a set of images

The example shown on the website is:
convert koala.gif blur_map_gradient.gif \
-compose blur -define compose:args=3 -composite \
blur_koala_gradient.gif
http://www.imagemagick.org/Usage/mapping
I'd like to do this for a whole directory of images.
I've looked into using mogrify, but can't figure out how to set the file input/output to run the process on a whole directory.
Thanks for any help.
You're on the right track with mogrify. To use your command as an example, you could do this:
mogrify -compose blur -define compose:args=3 -composite *.gif
This will apply the changes to all the images in the current directory. This will overwrite the images. If you do not want to overwrite the original images, you can either make a new directory (let's call it '/home/user/new/') or use the -format option to append a suffix to the files.
Here's an example with both options:
`mogrify -path /home/user/new/ -compose blur -define compose:args=3 -composite -format "blur.gif" *.gif
This will place originalimagename.blur.gif files in /home/user/new/, leaving the originals intact.
I was sure that it was possible to use -compose with mogrify. In actuality, mogrify does not recognize the -compose argument.. I think that your best bet is to use a script to loop through each image in the directory and use convert on them.

Batch resize images and output images to new folder with ImageMagick

Current image folder path:
public_html/images/thumbs
Output image folder path:
public_html/images/new-thumbs
I have 10 video thumbs per video in current folder, named of image thumbs:
1-1.jpg
1-2.jpg
1-3.jpg
1-4.jpg
1-5.jpg (Resize)
1-6.jpg
1-7.jpg
1-8.jpg
1-9.jpg
1-10.jpg
2-1.jpg
2-2.jpg
2-3.jpg
2-4.jpg
2-5.jpg (Resize)
2-6.jpg
2-7.jpg
2-8.jpg
2-9.jpg
2-10.jpg
I want to resize all 5th images(*-5.jpg) to the new folder. I've tried below command but no luck:
mogrify
-path
public_html/images/thumbs/*-5.jpg
-resize 16×12
-quality 100
public_html/images/new-thumbs/*-5.jpg
"Mogrify" should be called from the directory with the original thumbnails, while the -path parameter is for pointing target directory.
mkdir public_html/images/new-thumbs
cd public_html/images/thumbs
magick mogrify -resize 16x12 -quality 100 -path ../new-thumbs *.jpg
http://www.imagemagick.org/Usage/basics/#mogrify
The last arguments are the list of files, so you can filter by name 1-*.jpg for example.
Suggested solutions do not work properly on the latest ImageMagick (at least, on macOS).
Command, that works overwriting source images is as follows:
magick mogrify -path ./ -resize 50% -quality 80 *.jpg
To avoid overwriting the original images, write to a new folder:
magick mogrify -path path/to/destination/folder/ -resize 50% -quality 80 *.jpg
In ImageMagick 7 versions its built into the magick ...so..
magick mogrify -resize 16x12 -quality 100 -path ../new-thumbs *.jpg
Make sure that the folder you specify in path exists. It will not be created by ImageMagick.
Find more information here https://www.imagemagick.org/script/mogrify.php
For those having Shotwell installed on Ubuntu/Debian, following may be more easy to export selected images in a folder to another folder through processing the images as needed.
Open Shotwell
Select the images you want to export
File > Export
Adjust the values to your needs
Select the folder to export

Resources