[HN Gopher] ImageMagick: CLI for Image Editing
       ___________________________________________________________________
        
       ImageMagick: CLI for Image Editing
        
       Author : ijidak
       Score  : 95 points
       Date   : 2021-12-01 19:53 UTC (3 hours ago)
        
 (HTM) web link (imagemagick.org)
 (TXT) w3m dump (imagemagick.org)
        
       | pmarreck wrote:
       | If you ever need something actually performant or that uses far
       | less memory, have a look at libVIPS
        
         | jandrese wrote:
         | This is really interesting. In the past I've used netpbm for
         | this kind of work, but it has been on life support for at least
         | a decade now. I never used ImageMagick very much because each
         | time I tried I found a new and exciting crash bug somewhere in
         | the path, plus it tended to be much slower.
        
       | busymom0 wrote:
       | ImageMagick, ffmpeg, exiftool and YouTube-dl are 4 of the most
       | useful tools via command line.
        
         | naikrovek wrote:
         | youtube-dl seems to be abandoned, now. yt-dlp (an actively
         | developed fork of youtube-dl) seems to be it's accepted
         | replacement, I think.
         | 
         | fyi
        
           | busymom0 wrote:
           | You are correct. I switched to yt-dlp just couple days ago
           | (didn't remember the name when I was typing the comment).
           | YouTube-dl had started having issues where the download speed
           | was super slow and restarting the download also didn't work.
           | Yt-dlp fixed it.
        
       | khuey wrote:
       | https://xkcd.com/2347/
        
         | ninju wrote:
         | Reminds me of the tz database is maintained by one person
         | 
         | https://onezero.medium.com/the-largely-untold-story-of-how-o...
        
         | mkaic wrote:
         | wow, I thought the comic was already pretty applicable, and
         | then I read the alt-text!
        
       | pull_my_finger wrote:
       | Are there any [e]books focusing on ImageMagick? I use it a good
       | deal, but it's one of those things where you _know_ you're under-
       | utilizing it, and I'd like to take a deep dive with examples and
       | sage wisdom attached.
        
         | SavantIdiot wrote:
         | Totally agree with this. The documentation is very mid-1990's,
         | and every now and then I'll see a fork to it doing something
         | bonkers that I didn't know was in there.
        
       | coldpie wrote:
       | I always found it fascinating the grade-A executable names which
       | imagemagick was able to claim in the global namespace:
       | imagemagick /usr/bin/animate         imagemagick /usr/bin/compare
       | imagemagick /usr/bin/composite         imagemagick
       | /usr/bin/conjure         imagemagick /usr/bin/convert
       | imagemagick /usr/bin/display         imagemagick
       | /usr/bin/identify         imagemagick /usr/bin/import
       | imagemagick /usr/bin/mogrify         imagemagick /usr/bin/montage
       | imagemagick /usr/bin/stream
        
         | pavlov wrote:
         | No self-respecting Unix tool would use such long names, so
         | that's why they were free. "compare" vs "cmp", etc.
        
         | enobrev wrote:
         | This is something I always preferred about the graphicsmagick
         | fork, was the `gm` base command.
        
         | alerighi wrote:
         | import is the most fun, when you forgot the `#!/usr/bin/env
         | python` at the start of the script and of course the first
         | instruction is import and you get an ImageMagik error
        
         | ReaLNero wrote:
         | They are pretty common verbs, but they give 0 context to the
         | user on what they do. I don't think these names are in any
         | demand -- there's always a better name than "import" for your
         | command line utility.
        
           | majkinetor wrote:
           | Sounds like you want PowerShell style naming :)
        
         | HeckFeck wrote:
         | If executable names were traded like internet domains, imagine
         | what they'd be worth now.
        
           | technobabbler wrote:
           | I tried to convert those units but all I got was an
           | imagemagick error
        
         | nauticacom wrote:
         | Thankfully as of v7 these are all bundled under a single
         | "magick" command (with symlinks for compatibility). Hopefully
         | in the future these can be removed
        
         | wnevets wrote:
         | the latest versions recommend that you use magick convert
         | instead of just convert. I'm assuming because the globals are
         | going away.
        
           | banana_giraffe wrote:
           | "convert" always gave me trouble on Windows with some
           | existing tools that used Windows' built in "convert" tool. It
           | was an edge case, but always entertaining when the tool
           | needed to convert a filesystem or some tool I wrote wanted to
           | convert an image, and got the wrong executable.
        
         | herpderperator wrote:
         | This looks like useful output, what distro and command did you
         | use to list this?
        
           | coldpie wrote:
           | Arch Linux.                   $ pacman -Ql imagemagick | grep
           | bin         imagemagick /usr/bin/         imagemagick
           | /usr/bin/Magick++-config         imagemagick
           | /usr/bin/MagickCore-config         imagemagick
           | /usr/bin/MagickWand-config         imagemagick
           | /usr/bin/animate         imagemagick /usr/bin/compare
           | ....
           | 
           | You may also enjoy:                   $ pacman -Qo
           | /usr/bin/{display,convert}         /usr/bin/display is owned
           | by imagemagick 7.1.0.16-1         /usr/bin/convert is owned
           | by imagemagick 7.1.0.16-1
        
         | Meph504 wrote:
         | Image magick has been around for a pretty long time, and was
         | doing image processing on linux before most had considered it.
        
           | Maursault wrote:
           | ImageMagick was developed by John Cristy at DuPont in 1987
           | and release in 1990. Your statement is not only false, even
           | it it wasn't, mentioning Linux in relation to ImageMagick is
           | a non-sequitor. Maybe you should try other things.
        
       | eatbitseveryday wrote:
       | Don't forget GraphicsMagick!
       | 
       | http://www.graphicsmagick.org/
        
         | [deleted]
        
         | john-tells-all wrote:
         | GraphicsMagick is purportedly much better code and faster...
         | but people still reach for ImageMagick for some reason. Either
         | one is a wonderful, powerful tool!
        
       | dkuder wrote:
       | There are 634 CVE Records that match your search.
       | 
       | https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=imagemagick
       | 
       | There have been a number of zero days.
       | 
       | My entire interaction with Imagemagick has been removing it.
       | Often with great difficulty because there is some odd dependency.
        
         | chucky_z wrote:
         | Imagemagick is one of the few bits of software where the
         | functionality is worth the risk. Simply find a way to remove
         | any network access and use it. I used to run it in a docker
         | container with (almost) all capabilities dropped but with a
         | directory mapped into it to run.
        
           | bjackman wrote:
           | Not sure if this is common knowledge (??) but I feel I should
           | note here: in my job we absolutely do not consider containers
           | to be a security boundary[1]. On the other hand I still tend
           | to use them for isolation on my personal boxen, because they
           | at least reduce the blast radius of bugs or shitty packaging.
           | 
           | [1] Random search result that appears to corroborate my
           | claim: https://blog.aquasec.com/container-isolation
        
         | istjohn wrote:
         | I suppose it's probably a good idea to wrap it in a
         | microservice in production.
        
           | notreallyserio wrote:
           | Airgapped computer, it's the only way to be sure.
        
             | xbryanx wrote:
             | Printer output?
        
         | jmull wrote:
         | I guess this means you should not use imagemagick in any
         | process where the files (or other input) aren't trusted.
         | 
         | So you could use it in some typical dev workflows (or other
         | business workflows) that are purely internal and maybe in
         | certain non-internal processes where the inputs are strictly
         | limited to trusted ones. But not, e.g., in services/apps that
         | could process untrusted inputs.
         | 
         | (Seems like there are a number of leaks too, but since it's
         | process-oriented, those probably won't be that hard to live
         | with. They might be hard to notice normally.)
         | 
         | ?
        
         | pmarreck wrote:
         | > My entire interaction with Imagemagick has been removing it.
         | 
         | Same. I've successfully moved all my image manipulation
         | requirements to libVIPS. Far more performant and with a ton
         | less memory usage.
        
       | incanus77 wrote:
       | Such a good suite of utilities. When I first got on campus UNIX
       | in '95, I pretty quickly found this and tried in vain to get it
       | running on various versions of IRIX, Solaris, AIX, and whatnot.
       | Wasn't until I got Linux going that I could actually use it.
        
       | thesuitonym wrote:
       | ImageMagick is an incredible bit of kit. It really is a piece of
       | magic that surrounds us daily, that most people don't ever think
       | about, but is easy to use, and insanely powerful.
        
         | laurent123456 wrote:
         | Indeed there's a lot of very useful tools in there, with plenty
         | of options to create custom workflow. I used `compare` with the
         | fuzz option for instance to create a simple camera motion
         | detection:
         | https://github.com/laurent22/pmcctv/blob/e0930a0f7f51c319f66...
        
         | petercooper wrote:
         | Ditto for ffmpeg when you move into the audio or video realms.
        
           | kaladin-jasnah wrote:
           | ffmpeg, the command line tool, is wonderful, until you try
           | its library libav* (not to be confused with the ffmpeg fork).
           | The library is... a bit short of wonderful, at least in my
           | experience. Namely: there is basically zero official
           | documentation for it.
        
       | anthk wrote:
       | convert *.png output.pdf
       | 
       | Magic, indeed.
        
       | walrus01 wrote:
       | I don't know about using a CLI to edit images, but one of the
       | best thing of having imagemagick installed on my workstation
       | (it's an absolute essential) is the 'mogrify' CLI tool to batch
       | resize, manipulate or change formats of a whole directory full of
       | images.
       | 
       | https://imagemagick.org/script/mogrify.php
        
       | skrowl wrote:
       | This appears to just go to the the script page of
       | imagemagick.org. Is there something new or something else we
       | should be looking at here?
        
         | torstenvl wrote:
         | For each thing "everyone knows," there are tons of people
         | learning about it for the first time _right now_.
         | 
         | https://xkcd.com/1053/
        
           | petercooper wrote:
           | It's definitely a point worth remembering. I sometimes think
           | about AWS's one year free tier offerings and think.. WTF
           | doesn't have an AWS account and would still be signing up in
           | 2021? In reality it's probably a lot of people.
        
             | dragonwriter wrote:
             | > I sometimes think about AWS's one year free tier
             | offerings and think.. WTF doesn't have an AWS account and
             | would still be signing up in 2021?
             | 
             | AWS free tier offerings are _per account_ ; a person (or
             | organization) can have _lots_ of AWS accounts. The people
             | signing up for a new one today may well be people that
             | already have one.
        
             | MrDresden wrote:
             | I'm a dev with 11 years in the field and I've never touched
             | AWS. It is on the _todo_ list though, so I 'll get to it
             | eventually.
             | 
             | It can be easy to forget how vast this field truly is.
        
             | fknorangesite wrote:
             | People just keep being born.
        
         | eatbitseveryday wrote:
         | Likely this came about from a reader of a recent post also on
         | the front page [1] where image scaling is mentioned for website
         | loading performance.
         | 
         | > There's a million ways to skin the cat of image resizing,
         | whether you're using photoshop, gimp or a command line utility.
         | We like to use imagemagick when ever possible.
         | 
         | I notice this pattern. Someone posts, readers look at the
         | article / content and the comments, then find something else
         | interesting, and that thing then becomes another submission to
         | HN (either because it is indeed interesting on its own, or to
         | gain points due to relevancy of surrounding material on the
         | front page, or both).
         | 
         | [1] https://news.ycombinator.com/item?id=29405159
        
           | [deleted]
        
       | EamonnMR wrote:
       | I did a project where I scanned a bunch of old media. The scans
       | where so high quality that it was impractical to make a PDF for
       | people to use. The Imagemagick community helped out with the
       | right incantation to make everything just kinda work. One of the
       | rare cases where a project's maintainers will just help you use
       | it. I was wowed.
        
       | binarymax wrote:
       | Always my goto for any batch image manipulation. The documented
       | examples are varied and helpful, but it takes a little while to
       | get used to.
       | 
       | Here's one use of it in the wild, which batch takes a path of GAN
       | output files, each with a grid of thumbnails, and splits them
       | into individual images. Gloriously easy.
       | https://github.com/binarymax/matchbox-twelvy/blob/master/dcg...
        
       | wingmanjd wrote:
       | At my $OLDJOB, I used ImageMagick to compare snapshots during
       | some automated front-end testing on our public Drupal site. It
       | would compare the running test to previously accepted images,
       | highlighting pixel diffs in red. It would also generate a 4 frame
       | animated gif with of the original, highlit changes, the running
       | test version, and back to the highlit changes (so it could loop
       | for better comparison).
       | 
       | Imagemagick saved enormous amounts of time for us as we made CSS
       | and other module upgrades.
        
         | mch82 wrote:
         | Thanks for sharing this tip! Are there any guides you
         | recommend?
         | 
         | Edit: Here's one guide for the legacy Imagemagick (may not work
         | for the latest release),
         | https://legacy.imagemagick.org/Usage/compare/
         | 
         | I'm trying to encourage my front end developers to use visual
         | diffs to validate rendering rather than use Protractor to test
         | HTML/CSS.
         | 
         | I've known about BackstopJS,
         | https://garris.github.io/BackstopJS/ and am on the lookout for
         | alternatives.
        
           | majkinetor wrote:
           | Perceptual diff is another tool doing this:
           | 
           | http://pdiff.sourceforge.net
        
         | technobabbler wrote:
         | For the lazy geeks out there, the service diffy does this
         | easily and for cheap: https://diffy.website/
        
       | fnord77 wrote:
       | [1999]
        
       ___________________________________________________________________
       (page generated 2021-12-01 23:01 UTC)