Skip Menu |
 

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 91883
Status: open
Priority: 80/
Queue: Imager

People
Owner: Nobody in particular
Requestors: blue [...] thisisnotmyrealemail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Compatibility layer for ImageMagick/GraphicsMagick commands
Download (untitled) / with headers
text/plain 1.4k
Please consider adding support for ImageMagick commands. Since ImageMagick doesn't build cleanly off cpan and GraphicsMagick isn't even availble on cpan, Imager is the only choice for image processing for many of us. Often we prototype with the 'convert' command and get a working solution, but if we want to scale it up and avoid the system calls, things become very difficult. A lot of the google results for Imager show people wanting to convert their ImageMagick commands (example [1]). But either there's no simple/efficient way to do it or the documentation doesn't make it clear how to. (Example, binarize an image using a given threshold or autothresholding [2]). I propose adding a compatibilty layer to ImageMagick commands, so one could do something like $imager->magick('-gravity center -crop 36x15+0+0 -fuzz 15% -fill white +opaque black'), and it would parse the commands and convert it to the Imager implementations. The amount of effort would be non-trivial so this would be good for a community effort. Coordinating on questhub [3] might be a good idea. A small first step could be adding more recipes to the existing cookbook. There's a lot of questions on stackoverflow and perlmonks that could be added. A community wiki would also be helpful for this. [1] https://stackoverflow.com/questions/15462404/how-to-trim-images-with-imager [2] http://www.imagemagick.org/discourse-server/viewtopic.php?p=25468&sid=c3e61c576d40b5bda65cfa729f2a1429#p25468 [3] http://questhub.io/
Download (untitled) / with headers
text/plain 508b
Just for the record, here's my new article on installing Image::Magick under Debian: http://savage.net.au/ImageMagick/html/Installation.html. And, as for the project you propose, of parsing the command line parameters for convert etc, that would best be done by defining the BNF for those parameters, and using Marpa::R2. I'm thinking about it, but certainly have not committed myself to it. PS: I came across this ticket while writing Tree::Cladogram, which I released for the first time 10 minutes ago.
I've now started Image::Magick::CommandParser......
Download (untitled) / with headers
text/plain 975b
On 2016-01-02 00:57:46, RSAVAGE wrote: Show quoted text
> Just for the record, here's my new article on installing Image::Magick > under Debian: > > http://savage.net.au/ImageMagick/html/Installation.html.
And another just for the record, I have scripts for debian and freebsd, which install a suitable Image::Magick for a self-compiled perl: * https://github.com/eserte/srezic-misc/blob/master/scripts/install-imagemagick-on-debian.pl * https://github.com/eserte/srezic-misc/blob/master/scripts/install-imagemagick-on-freebsd.pl These differ from your solution as the Image::Magick is built against the system's ImageMagick package. Show quoted text
> And, as for the project you propose, of parsing the command line > parameters for convert etc, that would best be done by defining the > BNF for those parameters, and using Marpa::R2. I'm thinking about it, > but certainly have not committed myself to it.
Isn't BNF overkill here? Isn't a simple Getopt::Long parse of the command line sufficient here?
Download (untitled) / with headers
text/plain 361b
Show quoted text
> Isn't BNF overkill here? Isn't a simple Getopt::Long parse of the > command line sufficient here?
Usually, of course. But ImageMagick supports things like @file.name to incorporate text from file.name into the input stream. Does Getopt::Long support that? Anyway, I've released Image::Magick::CommandParser. It's based on Set::FA::Element, not Marpa::R2.
Download (untitled) / with headers
text/plain 1.7k
On Sun Jan 05 17:23:06 2014, blue wrote: Show quoted text
> Please consider adding support for ImageMagick commands.
It's not something I'm inclined to add to the Imager core. If you want to create a module that adds Imager::magick() I won't object. Show quoted text
> A lot of the google results for Imager show people wanting to convert > their ImageMagick commands (example [1]). But either there's no > simple/efficient way to do it or the documentation doesn't make it > clear how to. (Example, binarize an image using a given threshold or > autothresholding [2]).
One problem is Imager doesn't do a lot of the things ImageMagick does, though hopefully that will change over time. In the short/medium term I'm working on fixing Imager's color handling (#96204, #54992). Show quoted text
> A small first step could be adding more recipes to the existing > cookbook. There's a lot of questions on stackoverflow and perlmonks > that could be added. A community wiki would also be helpful for this.
I had a wiki at one point, it never had much content, and all of the content was supplied by me. Show quoted text
Imager doesn't have an auto-trim function. (#60624) Show quoted text
> [2] http://www.imagemagick.org/discourse- > server/viewtopic.php?p=25468&sid=c3e61c576d40b5bda65cfa729f2a1429#p25468
Trying to do this revealed a bug in Imager, I get really close with: perl -Mblib -MImager -e '$im = Imager->new(file => shift) or die; $g = $im->convert(preset => "grey"); $p = $g->to_paletted(max_colors => 2, make_colors => "mediancut", translate => "errdiff"); $p->filter(type => "autolevels"); $p->write(file => shift)' infile outfile except for the bug (#91883) Adding another: $p = $p->to_paletted(make_colors => "mono"); fixes that for my test image. Tony


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.