Git Product home page Git Product logo

Comments (5)

Danack avatar Danack commented on June 22, 2024

So. Imagick uses the ImageMagick library underneath through the MagickWand API. ImageMagick also has command line tools, which mostly expose the same functionality, however.....

ImageMagick has different expectations for users. The command line tools will normally try to guess the right behaviour, whereas with the API it will do exactly as told, which can be annoying.

Also, not all of the functionality available in the command line tools of ImageMagick are exposed 'neatly' for re-use through an API.

Is there any way to translate the Examples from https://imagemagick.org/script/ into PHP code?

It's reasonably fine to just run those scripts through exec or one of the other ways of running stuff on the command line.

In general there should be an equavalent call to the class Imagick - or not?

Usually, but not always.

But convex hulls should be possible through the morphology method

That code is meant to give a convex hull output similar to the example on ImageMagick.

However it doesn't appear to be doing the right thing. I'll need to investigate if I'm just misremembering, or it's borken.

from imagickdemos.

Danack avatar Danack commented on June 22, 2024

Yeah, the output of the link above is meant to be:

convexy

But apparently the output is wrong when building against the current version of Imagick. I'll investigate tomorrow.

from imagickdemos.

Danack avatar Danack commented on June 22, 2024

Oh. The code works.....but the server is timing out, and so keeps displaying the previous image on the page. Which is a different problem, but that is some code that convex hulls stuff.

from imagickdemos.

cmette avatar cmette commented on June 22, 2024

Thank you very much for your quick reply!

Probably I have the same timeout problem here. I get blank or the original images when deskewing and cropping photos. That's my overall goal. Either with convexHull or with deskew() + trim(). it's all the same - whichever is better.

I start as follows:

$fname = "6947";  # you can see 6947 below this code

$src = "files/test/$fname.jpg";
$imagick = new \Imagick();
$imagick->readImage(TL_ROOT . '/' . $src);
$html .= $this->ImgToHtml($src, $imagick, "Original");

$imagick->despeckleImage();

This is my source from the scanner:

6947

It should be deskewed in the first step with the following code - this does not work on any server:

$src = "files/test/$fname.deskew.jpg";
#$imagick->setImageBackgroundColor(new ImagickPixel("rgb(254,254,254)"));
$result = $imagick->deskewImage(0);
$imagick->writeImage(TL_ROOT . '/' . $src);
$html .= $this->ImgToHtml($src, $imagick, "deskew: 0");

The result is:
6947 deskew
You can see here, deskew is not working (with any parameter from zero to 100)

In the next step i try to trim/autocrop the image with the following code.

$src = "files/test/$fname.trim1.jpg";
#$imagick->setImageBackgroundColor(new ImagickPixel("rgb(254,254,254)"));
$fuzz = 60000;
$result = $imagick->trimImage($fuzz);
$imagick->writeImage(TL_ROOT . '/' . $src);
$html .= $this->ImgToHtml($src, $imagick, "trim1 fuzz: $fuzz");

This is the result:
6947 trim1

The fuzz parameter is not well documented. I can't find any detailed information on how it works exactly.

For the previous image, trimImage() happens to work with the value 60000, but this is not true for all my images (3500), and there seems to be no documentation or algorithm that I can use to calculate the fuzz parameter so that it performs an exact trim on arbitrary images.

At the moment it seems that deskew and trim/autocrop do not work with IMagick 7.1.0.18? Is this true?
Or am I making a serious mistake here?

Best regards
Theo

from imagickdemos.

cmette avatar cmette commented on June 22, 2024

ping

from imagickdemos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.