2015-12-24: The post and both scripts have been updated to work with magick
(IMv7)
Here are a couple of tiny scripts/helpers to help you with images… I use them almost everyday. One is to quickly make a jpg image, and the other one is to make thumbnails/miniatures …or at least, smaller images.
Since I move between Linux and OS X, they’re made to work on both. I have ImageMagick installed in my OS X, but I added sips
»» (fallback) for those who doesn’t. But it will look for magick
(IMv7) or convert
(IMv6) on both as the default tool.
mkjpg
This is used just to be able to convert an image to a jpg real quick. Perfect for screenshots etc, where the settings usually are set to png or tiff. They can get quite large in filesize, so just by typing mkjpg
and drag’n’drop the image into the terminal window is really a time saver - instead of open up an image editor, fiddle through menues, export/save as, etc etc… Helps me out (almost) every day.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
Install
Save it as mkjpg
, and install it. I keep mine in my own “xbin” folder: /usr/local/xbin
.
sudo install -v -m 755 mkjpg /usr/local/xbin;
# Verify
which mkjpg
ls -Ahl /usr/local/xbin/mkjpg
Usage
# mktjpg <image> [<procent>]
mkjpg Image.png
mkjpg Image.png 60
mkthumb
This one takes an image and creates a thumbnail/miniature of it. If no argument is added after the image path, it will default to 250px (wich are the desired size on the Arch forum, for example). Max size is set to 500. Larger images really doesn’t qualify as a “thumb”.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
Install
Save it as mkthumb
, and install it. I keep mine in my own “xbin” folder: /usr/local/xbin
.
sudo install -v -m 755 mkthumb /usr/local/xbin;
# Verify
which mkthumb
ls -Ahl /usr/local/xbin/mkthumb
Usage
# mkthumb <image> [size]
mkthumb Image.jpg
mkthumb ~/Desktop/Another_Image.jpg 400
That will create:
Image_250px.jpg
~/Desktop/Another_Image_400px.jpg
Note(s) on ImageMagick
There’s a new version around (, up&coming)… I upgraded ImageMagick the other day and installed the git version. That is the new ImageMagick7 (nextgen). It’s great and has a few new intresting stuff in there, but also - it replaces convert with magick
- leaving a symlink: convert -> magick
.
The scripts above are updated to work with both.
If you have ImageMagick7, but also want/need IMv6, you could install it into a separate folder. Here’s what I did…
I have ImageMagick7 installed as normal in /usr/local
. Then I also have ImageMagick-6.9.2 installed, using --prefix=/usr/local/ImageMagick6
*, then I replaced the symlink to point at the IMv6 version: convert -> /usr/local/ImageMagick6/bin/convert
.
$ cd /usr/local/bin
$ sudo ln -s ../ImageMagick6/bin/convert .
$ ls -Ahl convert
Or you could keep the symlink to magick
and add convert.6
or something like that. If scripting with convert
with IMv7, it will throw an error that you should use magick
directly.
* Not only for this, but also for the imagick
extension in PHP. I never got to compile against ImageMagick7.
If your interested in the new ImageMagick7, or want/need to install ImageMagick. Here are some links…
- ImageMagick.tar.gz (latest stable)
- Message Digest (checksums)
- Downloads
- Downloads (beta)
- How to install
- A page about the “NextGen ImageMagick”
- ImageMagick @ Github
There are a page with binaries to, for those who can’t/won’t install from source.
Happy hacking…
/Eric