PS with Perl ActiveState using OLE

S
Posted By
Slickuser
Jan 1, 2008
Views
568
Replies
1
Status
Closed
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";

How to Master Sharpening in Photoshop

Give your photos a professional finish with sharpening in Photoshop. Learn to enhance details, create contrast, and prepare your images for print, web, and social media.

LV
l v
Jan 1, 2008
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

Master Retouching Hair

Learn how to rescue details, remove flyaways, add volume, and enhance the definition of hair in any photo. We break down every tool and technique in Photoshop to get picture-perfect hair, every time.

Related Discussion Topics

Nice and short text about related topics in discussion sections