Hi Monks,

I try to resize images with Adobe Photoshop using Win32::OLE. I've written the following script:

#! /usr/bin/perl use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Adobe Photoshop'; my $image_file = './atemschutzmaske.jpg'; # start photoshop my $ps = Win32::OLE->new('Photoshop.Application') or die $!; $ps->{Visible} = 0; # open image my $desc = $ps->MakeDescriptor(); my $control = $ps->MakeControlObject(); $desc->PutPath(phKeyNull,$image_file); $control->Play(phEventOpen,$desc,phDialogSilent); # autolevels $desc = $ps->MakeDescriptor(); $control = $ps->MakeControlObject(); $desc->PutBoolean(phKeyAuto, 1); $control->Play(phEventLevels,$desc,phDialogSilent); # resize to 400 * 400 px $desc = $ps->MakeDescriptor(); $control = $ps->MakeControlObject(); $desc->PutUnitDouble(phKeyWidth, phUnitPixels, 400); $desc->PutBoolean(phKeyConstrainProportions, 1); $desc->PutEnumerated(phKeyInterfaceIconFrameDimmed,phTypeInterpolation +,phEnumBicubic); $control->Play(phEventImageSize,$desc,phDialogSilent); $control = $ps->MakeControlObject(); my $d1 = $ps->MakeDescriptor(); my $d2 = $ps->MakeDescriptor(); $d2->PutEnumerated(phKeyPNGInterlaceType,phTypePNGInterlaceType,phEnum +PNGInterlaceNone); $d2->PutEnumerated(phKeyPNGFilter,phTypePNGFilter,phEnumPNGFilterAdapt +ive); $d1->PutObject(phKeyAs,phClassPNGFormat,$d2); (my $outfile = $image_file) =~ s/\.jpg/_thumb.png/; print $outfile,"\n"; $d1->PutPath(phKeyIn,$outfile); $d1->PutBoolean(phKeyLowercase, 1); $control->Play(phEventSave,$d1,phDialogSilent); $desc = $ps->MakeDescriptor(); $control = $ps->MakeControlObject(); $control->Play(phEventClose,$desc,phDialogSilent);


But I get the following error message:
Bareword "phKeyLowercase" not allowed while "strict subs" in use at ps +_skript.pl line 46. Execution of thumbcreator.pl aborted due to compilation errors.


If I leave the line $d1->PutBoolean(phKeyLowercase,1);, Photoshop is started, but no Thumbnail is created.

Now I have two questions:
*) Why is no thumbnail created? Where is the mistake in the code?
*) Is there a list of Photoshop-functions I can use with Perl?

thanks, Renee

In reply to using Photoshop via Perl by reneeb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.