PS with Perl ActiveState using OLE

568 views1 repliesLast post: 1/1/2008
Hi all,

I don't know what is the format to resize the image from Perl PS OLE. Here is the API, Sub ResizeImage([Width], [Height], [Resolution],
[ResampleMethod])
change the size of the image.

I try put as numbers and 800px for my width in a String and it doesn't
work either.
Any help?
Other method work.

use Win32::OLE;
use OLE;
use Cwd;

my $Photoshop = Win32::OLE->new('Photoshop.Application') or die "Can't start Photoshop!\n";
$Photoshop->{'Visible'} = 0;

my $cwd = getcwd();
$sourceImageFileName = $cwd."/800.jpg";

my $Document = $Photoshop->Open($sourceImageFileName) or die "Can't open $sourceImageFileName.\n";

my $width = "800 pixels";
my $height = "600 pixels";
my $resolution = "96 pixels/inch";
my $resample_method = "Bicubic";
my $rotate = 0;

$Document->ResizeImage($width,$height,$resolution,$resample_method); #$Document->SaveAs("C:/test.jpg");

if ($rotate) {
$Document->RotateCanvas(-90.0);

}

$Document->Save();
$Document->Close;

print "Width: $width, Height: $height\n";
#1
Slickuser wrote:
Hi all,

I don't know what is the format to resize the image from Perl PS OLE. Here is the API, Sub ResizeImage([Width], [Height], [Resolution],
[ResampleMethod])
change the size of the image.

I try put as numbers and 800px for my width in a String and it doesn't
work either.
Any help?
Other method work.
[code snip]
my $width = "800 pixels";
my $height = "600 pixels";
my $resolution = "96 pixels/inch";

Instead, try:
my $width = '800';
my $height = '600';
my $resolution = '96';

my $resample_method = "Bicubic";
my $rotate = 0;
[code snip]

You might want to look at ImageMagick (executable and Perl modules) to do this type of work. It would be alot quicker than using PS if all you are resizing are jpeg images.

Additionally, Photoshop (CS+) has a good Image Processor which converts and processes multiple files. It works with works with Photoshop (PSD), JPEG, and camera raw files and allows you to resize the image to fit within the dimensions you enter and retains the images original proportions. You can find it under File > Scripts > Image Processor

--

Len
#2