Re: Evaluate/Operator in perl API

Bob Friesenhahn <[email protected]> Thu, 17 Sep 2015 08:51:36 -0500 (CDT)
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

---559023410-795000706-1442497896=:1673
Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by blade.simplesystems.org
	id t8HDpa8Y003892

On Wed, 16 Sep 2015, Didster wrote:

> Hi,
> I'm looking to switch to GM from IM for a script that I have that proce=
sses around about 60,000 images as IM is
> god awful slow after the first 1000 or so, even with MP support complie=
d out.=C2=A0 Each source image is resized to a
> number of destination sizes by:
>=20
> 1. Resize the actual image, if the destination is smaller
> 2. Center the actual image in a white background the size of the destin=
ation
> 3. Overlay a "watermark" which has been made transparent to different l=
evels using IM
>=20
> For step 2, I was using IM->Extent() which doesnt seem to exist in GM s=
o instead I'm now creating a blank white
> background and Composing the image over the top, that works fine.

I must apologize for not keeping the PerlMagick API in sync with the=20
GraphicsMagick APIs.  The enumeration values have been kept in sync,=20
but I have not been adding new commands like 'extent' or 'operator'.=20
Regardless, the GraphicsMagick variant of PerlMagick should run well=20
since it is an important part of the test suite.

Software which runs slower and slower may be running slower due to=20
memory leaks.

Thousands of memory leaks have been fixed in GraphicsMagick since the=20
fork from ImageMagick.  ImageMagick was originally utilities which ran=20
and then quit so memory leaks were not very important.

On Unix type systems, there is a simple "fix" for memory leak problems=20
in a leaky PerlMagick.  The "fix" is to do all image processing in a=20
forked process (fork()) which quits after processing a few images.

> For step 3, I was using something like this:
>=20
> $wmFileHandle->Evaluate(
> =C2=A0operator =3D> 'Multiply',
> =C2=A0value =C2=A0 =C2=A0=3D> $opacity,
> =C2=A0channel =C2=A0=3D> 'Alpha',
> );
>=20
> Where $opacity is an float from 0.0 to 1.0.
>=20
> What would be the equivalent in GM for Perl?=C2=A0 I know using convert=
 its "-operator" e.g.
>=20
> gm convert input.png -operator Opacity Multiply 0.5 output.png

Perhaps using one of the Composite operators would suffice.  It is=20
possible to insert an opacity channel using CopyOpacity.  I would need=20
to study the math to see if others may be used to manipulate the=20
opacity.

> I have also tried leaving the watermark as fully opaque and then using=C2=
=A0
>=20
> $mainImageHandle->Composite( compose =3D> 'Over', image =3D> $wmFileHan=
dle, opacity =3D> $opacity );
>=20
> But that gives corruption [the same problem I was having with IM, which=
 lead me to switch to Evaluate]

What do you mean by "corruption"?  Are you able to share some sample=20
images as well as the desired result?

Don't ignore the 'Montage' operator.  It may be convinced to do=20
exactly what you want.

Bob
--=20
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen=
/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
---559023410-795000706-1442497896=:1673
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
---559023410-795000706-1442497896=:1673
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Graphicsmagick-apis mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-apis

---559023410-795000706-1442497896=:1673--