ImageMagick 'convert -sepia-tone' different on Windows vs. Linux - windows

I have an issue with the 2 images below: the first one is created on Linux, the second one on Windows using the same command, same versions of ImageMagick (6.6.5-0). Tried newer versions of ImageMagick and they all seem to provide different results Windows vs. Linux.
convert c.jpg -sepia-tone 80% 1.jpg (on Linux)
convert c.jpg -sepia-tone 80% 2.jpg (on Windows)
The results are very different and I cannot figure out why.
What am I doing wrong?
(source: selfip.com)
(source: selfip.com)

I actually had to do
convert c.jpg -set colorspace RGB -sepia-tone 80% 1.jpg
basically forcing the use of the RGB colorspace and that solved my problem.

Most likely, the release versions of your ImageMagick installations on Linux and Windows are different in more ways than the mere version numbers...
To verify, run this command and compare the outputs in detail for the two platforms:
convert -version
Additionally, you may want to see how the outputs for convert -list configure differ. (Note, the format of the outputs this command gives is different anyway on the two platforms -- they are not directly comparable).

Related

ImageMagick mogrify stopped working with a great amount of images

When using
mogrify -format png *.ppm
with a couple of images it works, but when I tried with a great amount of files(Around 20 million) it does not show an error message but after a some minutes the CLI will appear as if it had finished the task but when checking my folder I do not have a single png, I work in windows and have 8 Gigabytes of RAM, so I was wondering:
Does ImageMagick has a limit for the quantity of images?
Or is it just that my computer is not powerful enough for the task?
The files have around 400 Megabytes in total.
Also if there is any other way to get the images into png format even if losing the ppm version please let me know.
Did you check your ImageMagick policy.xml file?
It should be at homeDirectory/.config/ImageMagick/policy.xml
There are limitations that you can set in that file.
Might want to check Imagemagick security policy page
Two ideas...
Firstly, use:
mogrify -verbose -format png *.ppm
so you see what's going on.
Secondly, you could try creating a list of files to process like this:
DIR *.ppm /S /B > filelist.txt
Then tell ImageMagick to process that list of files with:
mogrify -format png #filelist.txt
Another idea... try using double quotes:
mogrify -format png "*.ppm"

Remove grey background and turn it transparent

ImageMagick does not replace '#c0c0c0' with a transparent background
I have tried magick convert img.png -fuzz 50% -transparent '#c0c0c0' 0.png and a convert option without "magick"
running version windows 10 x64 v7.0.8-14Q16 .
A problem for later: using a bash script to convert 200 of these and it seems imagemagick also doesn't overwrite if output name is the same
here is the image: https://i.imgur.com/JnNBtpX.png
No change...
Strangely it is just a problem with windows? Tried it on linux and it works fine.

Imagemagick fonts not found in OSX

When trying to add annotations to images in ImageMagick, It failed with the following message:
convert: unable to read font `(null)' # error/annotate.c/RenderFreetype...
How do I make Imagemagick find these fonts?
The solution that worked for me was given by Neville in this post:
Create an imagemagick configuration folder: mkdir ~/.magick
Save this Perl script as /tmp/script.pl
Make the script executable: chmod +x /tmp/script.pl
Run the script locally and redirect the output to the file type.xml in ~/.magick: /tmp/script.pl > ~/.magick/type.xml
This solved the fonts problem, while installing fondu, the imagemagick pkg file and some other tricks didn't.
Great! Now I can annotate some flickr cats with the image size and resolution (I want this for finding the optimal resolution for an app I'm working on).
Adopting Adam Matan's answer, here's how I got this to work with imagemagick 7+ on macOS 10.12+ installed with homebrew. (This also assumes you have perl installed.)
Download the perl script and save it to /usr/local/bin/imagick_type_gen
Make the script executable:
chmod +x /usr/local/bin/imagick_type_gen
Find the font path for imagemagick by running convert -list font | grep Path. This should return where imagemagick is looking for fonts. The Apple path for me was this:
/usr/local/Cellar/imagemagick/7.0.7-22/etc/ImageMagick-7/type-apple.xml
Run imagick_type_gen and direct the output to the path above:
imagick_type_gen > /usr/local/Cellar/imagemagick/7.0.7-22/etc/ImageMagick-7/type-apple.xml
Run convert -list font | less to see the font names imagemagick will use, e.g., some fonts will be labeled as GeorgiaB instead of Georgia Bold. (hit q to quit)
imagemagick should now see the fonts you have installed on the your system.
The easiest way to solve this issue is copying the font you need to a ~/ folder, or anywhere your script is, then give the direct path:
convert -font "~/MyFont.ttc"

Run specific executable with conflicting name within clojure.java.shell

I have two executables named convert.exe in my PATH. One of them is from ImageMagick, the other is from Windows.
user=> (clojure.java.shell/sh "where" "convert")
{:exit 0, :out "E:\\Program Files\\ImageMagick-6.8.3-Q16\\convert.exe\r\nC:\\Windows\\System32\\convert.exe\r\n", :err ""}
I would like to run ImageMagick's convert.exe within clojure.java.shell/sh. Normally, I can do this within PowerShell.
PS E:\Users\bt> convert --version
Version: ImageMagick 6.8.3-8 2013-03-04 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib fontconfig freetype jng jp2 jpeg lcms lzma pango png ps tiff x xml zlib
However, this does not work within clojure.java.shell/sh.
user=> (clojure.java.shell/sh "convert" "--version" :dir "E:/Users/bt")
{:exit 4, :out "", :err "Invalid drive specification.\r\n"}
Initially, I thought that I needed to move the path to ImageMagick to the front of my PATH so that it would gain precedence over Windows' binary, but that didn't have any effect. Also, I moved it to the end of the PATH just for kicks. That also didn't work.
The only alternative I know that resolves this is to rename either of the executables. But this is undesired because I do not want others to rename their ImageMagick/Windows binaries just to make my code work.
If this information is of any use, opening a new command shell (not PowerShell, but cmd.exe) starts in C:\Windows\System32. I have a feeling that this might affect the choice of executable, but I'm not sure. This only happens if I run cmd.exe from Launchy. If I use the Start Menu, it'll start in my home directory.
Is there any way to do this? I feel like I'm missing something obvious.
I can reproduce your results. Whatever the reason is, it's buried somewhere with Java's Runtime.exec which receives the PATH, but maybe it adds the Windows System dir in front?
If you want to understand it thoroughly, this is where you should continue investigation.
See the call to it in sh:
(let [...
proc (.exec (Runtime/getRuntime)
(into-array cmd)
(as-env-string (:env opts))
(as-file (:dir opts)))]
It does work if you give an absolute path to the executable, however. So, here are two options how you can solve the problem:
If it is safe to assume that the IM convert.exe is the first on the PATH, just execute "where" as you showed in your question, take the first path from the :out which is returned, append convert.exe to it and use the result as program to sh.
If you cannot assume a correct PATH, ask the user where Image Magick is installed and store the program path somewhere. Prepend this to the program path.
Can you try giving the absolute PATH for the executable?
like,
user=> (clojure.java.shell/sh "E:\\Program Files\\ImageMagick-6.8.3-Q16\\convert.exe" "--version" :dir "E:/Users/bt")
OR
user=> (clojure.java.shell/sh "E:\\Progra~1\\ImageMagick-6.8.3-Q16\\convert.exe" "--version" :dir "E:/Users/bt")

Via command line: convert (.tif and .pdf) to .jpg or .png

anyone know a free, stable commandline tool (besides ImageMagick) to convert .tif files and .pdf files to either .jpg or .png?
thanks Michelle
I prefer Imagemagick for Windows stuff, but IrfanView performs well, too. It looks like it has switches for command-line conversion of image formats, as well. See the "/convert" option.
tiff2png
On mac os x:
$ brew install tiff2png
$ tiff2png -compression 9 *.tif

Resources