12 ms·
ImageMagick: CLI for Image Editing
- ComputerGuru 5y agoSee also vips and libvips, presenting a much cleaner library interface and faster processing: https://www.libvips.org/ https://www.libvips.org/
- jaxomlotus 5y agoechoing this. I've been playing with this library and it's great!
- skunkworker 5y agoI also echo this, I would go for VIPS first unless there are certain things that imagemagic can do that VIPS can't. You'll cut down on your memory usage significantly (like 500mb down to 20mb) and also use much less CPU.
- pull_my_finger 5y agoAre 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 5y agoTotally 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.
- skrowl 5y agoThis 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 5y agoFor each thing "everyone knows," there are tons of people learning about it for the first time right now. https://xkcd.com/1053/ https://xkcd.com/1053/
- petercooper 5y agoIt'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.
- MrDresden 5y agoI'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 5y agoPeople just keep being born.
- dragonwriter 5y ago> 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.
- eatbitseveryday 5y agoLikely 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 https://news.ycombinator.com/item?id=29405159
- wingmanjd 5y agoAt 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 5y agoThanks 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/ 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/ https://garris.github.io/BackstopJS/ and am on the lookout for alternatives.
- majkinetor 5y agoPerceptual diff is another tool doing this: http://pdiff.sourceforge.net http://pdiff.sourceforge.net
- bkyan 5y agoI would recommend generating an animated .webp for the diff output, which ImageMagick supports. Animated GIFs have color resolution limits.
- bkyan 5y agoA note of caution if you're planning to use Puppeteer for screenshots -- One oddity I've experienced with Puppeteer, is that there are sometimes very small height differences between headless and non-headless modes when generating screenshots. I suspect the root cause is that they are rounding sub-pixels differently, in certain scenarios. So, I typically run Puppeteer locally with { headless: false } to try to get a pixel-perfect match to the regular desktop Chrome experience.
- eatbitseveryday 5y agoDon't forget GraphicsMagick! http://www.graphicsmagick.org/ http://www.graphicsmagick.org/
- deleted 5y ago[deleted]
- john-tells-all 5y agoGraphicsMagick is purportedly much better code and faster... but people still reach for ImageMagick for some reason. Either one is a wonderful, powerful tool!
- thesuitonym 5y agoImageMagick 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.
- petercooper 5y agoDitto for ffmpeg when you move into the audio or video realms.
- kaladin-jasnah 5y agoffmpeg, 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 5y agoffmpeg for video/audio, sox for audio fx.
- laurent123456 5y agoIndeed 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/e0930a0f7f51c319f66d43990b2347d225f6c1dd/main.go#L84 https://github.com/laurent22/pmcctv/blob/e0930a0f7f51c319f66...
- walrus01 5y agoI 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 https://imagemagick.org/script/mogrify.php
- TylerE 5y agoIt's very handy for stuff like manipulating image uploads.
- coldpie 5y agoI 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
- enobrev 5y agoThis is something I always preferred about the graphicsmagick fork, was the `gm` base command.
- pxc 5y agoI came here to say the same thing
- alerighi 5y agoimport 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 5y agoThey 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 5y agoSounds like you want PowerShell style naming :)
- ReaLNero 5y agoWith good autocomplete, I wouldn't mind it! I was honestly thinking of stuff like `du` (disk usage), `cp`, `mv`, and the like. Like I sort of mnemonically remember them, compared to mentally mapping `convert` -> imagemagick.
- dkuder 5y agoThere are 634 CVE Records that match your search. https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=imagemagick 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 5y agoImagemagick 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 5y agoNot 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 https://blog.aquasec.com/container-isolation
- zamadatix 5y agoThe article's sources disagree with the article. Its link to Microsoft's definition of a security boundary explicitly includes containers as a security boundary twice in the tables and offers bounties if you can break out of that security boundary. Its link and quote from Google say it's not a _strong_ security boundary yet the article claims Google said it wasn't a security boundary at all. The Red Hat link doesn't say anything about security boundaries whatsoever but it does say containers aren't perfect protection yet they do provide some protection. The Netflix link also explicitly says containers are a security boundary multiple times and they use additional protections to strengthen that boundary. At this point I'm doing following citations but you get the point. If the security folks at your job truly doesn't consider containers security boundaries then they are wrong. What seems more likely is they don't consider containers alone a _good enough_ security boundary. And that's fine, some places consider separate processes with different rights good enough security boundaries. Others consider two boxes that are able to interact with each other not a good enough security boundary. It doesn't change that things that weren't secure enough for the use case are still security boundaries.
- anthk 5y agoconvert *.png output.pdf Magic, indeed.
- khuey 5y agohttps://xkcd.com/2347/ https://xkcd.com/2347/
- mkaic 5y agowow, I thought the comic was already pretty applicable, and then I read the alt-text!
- ninju 5y agoReminds me of the tz database is maintained by one person https://onezero.medium.com/the-largely-untold-story-of-how-one-guy-in-california-keeps-the-worlds-computers-on-the-right-time-a97a5493bf73 https://onezero.medium.com/the-largely-untold-story-of-how-o...
- EamonnMR 5y agoI 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.
- jackvalentine 5y agoWas this on a public forum you can link?
- timonoko 5y agoI do book scanning a lot. Somebody might find these simple scripts useful: https://github.com/timonoko/BookScanner https://github.com/timonoko/BookScanner
- EamonnMR 5y agoDiscussion (with script) here: https://github.com/ImageMagick/ImageMagick/discussions/3124 https://github.com/ImageMagick/ImageMagick/discussions/3124 The resulting PDFs are here: https://archive.org/details/@eamonnmr https://archive.org/details/@eamonnmr
- pmarreck 5y agoIf you ever need something actually performant or that uses far less memory, have a look at libVIPS
- jandrese 5y agoThis 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.
- pmarreck 5y agoMost people have probably moved onto just using someone else to host and manipulate their images, but for business reasons, one of my apps stores its images (and all the cached sizes) in the DB (single source of truth is also nice) so switching to libVIPS enabled me to reduce the amount of compute resources I pay for
- busymom0 5y agoImageMagick, ffmpeg, exiftool and YouTube-dl are 4 of the most useful tools via command line.
- naikrovek 5y agoyoutube-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
- code_biologist 5y agoThank you for the heads up! Been sad to see the site list that youtube-dl works on slowly degrade and shrink.
- busymom0 5y agoYou 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.
- incanus77 5y agoSuch 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.
- binarymax 5y agoAlways 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/dcgan/frames-from-samples.sh https://github.com/binarymax/matchbox-twelvy/blob/master/dcg...
- fnord77 5y ago[1999]
- undoware 5y agoseeing ImageMagick, of all hoary tools, trending on HN reminds me that I'm so old that the kids are relishing as classics the tools I regard as outdated. This is expectable in music, but in tooling? And with Image-frigging-Magick ? Damn. Looking forward to the front-page HN-trended article on `sendmail`
- anthk 5y agoThe next ones will be mplayer, XFig, XPDF, nmh, TKGate for electronic boards, Links and Bochs. Back to 2002 again.
- undoware 5y agomy default browser is.... [sunglasses emoji] Arena
- anthk 5y agoWell, a lot of people use links -g and Netsurf daily :p. HN works on texts, lots of blogs are plain text, and ofc you have http://68k.news http://68k.news, https://lite.cnn.io https://lite.cnn.io and https://text.npr.org https://text.npr.org.
- sandreas 5y agoIf you wanna convert images for web, I use tools like: svgo (SVG Optimization) colorist / avifenc (AVIF) cwebp (webp) convert (ImageMagick, everything else) because ImageMagick is able to convert MOST of thse, but not every format. https://github.com/svg/svgo https://github.com/svg/svgo https://github.com/joedrago/colorist https://github.com/joedrago/colorist https://developers.google.com/speed/webp/docs/cwebp https://developers.google.com/speed/webp/docs/cwebp https://imagemagick.org/ https://imagemagick.org/