Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: using Photoshop via Perl

by !1 (Hermit)
on Dec 27, 2004 at 13:03 UTC ( #417540=note: print w/replies, xml ) Need Help??

in reply to using Photoshop via Perl

*) phKeyLowercase does not exist. Perhaps you should be trying phKeyLowerCase?

*) This should generate a list of all the constants that it exports:

#!/usr/bin/perl -wl package ap; use Win32::OLE::Const "Adobe Photoshop"; package main; $, = $/; print sort grep defined *{"ap::$_"}{"CODE"}, keys %ap::;

Update: Hopped over to a machine that actually has AP on it and discovered that your code still doesn't work. Corrected version included in the readmore.

#! /usr/bin/perl use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Adobe Photoshop'; use File::Spec; my $image_file = './pic.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 = File::Spec->rel2abs($image_file)) =~ s/\.jpg$/ +g/; 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);

Replies are listed 'Best First'.
Re^2: using Photoshop via Perl
by reneeb (Chaplain) on Dec 27, 2004 at 23:28 UTC
    Thanks for your code. It works fine.
Re^2: using Photoshop via Perl
by JamesNC (Chaplain) on Dec 29, 2004 at 12:15 UTC
    Great job !1 Excellent reply!!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://417540]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2021-07-23 18:51 GMT
Find Nodes?
    Voting Booth?

    No recent polls found