Strange behavior with CS script

Hi

The idea with this script it create a colour and desaturated version of the same picture with in the same document. They would appear side by side.


tell application "Adobe Photoshop CS"
	activate
		select all current document
	copy
	adjust layer 1 of current document using desaturate
	set x to width of current document
	set w to x * 2
	resize canvas of current document width w anchor position middle left
	paste
	set q to x / 2
	translate layer 1 of current document delta x q delta y 0
	end tell

This works fine with images whose resolution is 72 but not with images whose resolution is 300 !??
When I run it on 300 ppi images ther copy picture disappears from the document.

I thought it might some sort of bug and tried the same script with CS3 but CS3 won’t let me use the desaturate class
I even copied the code direct from the adobe website


tell application "Adobe Photoshop CS3"
		adjust current layer of the current document using desaturate with options {class: desaturate}
end tell

This produces an error of Can’t make data into expected type
Any ideas would as always be appreciated

Hi

I didn’t get an error in CS2, if that helps!!

Although the images weren’t exactly side by side overlapped quite a bit.
No error though!

Thanks Pidge

But they should not overlap if the maths is right (which I think it is)

CS pastes the copy of the image in the centre of the document which is then moved one quarter of the width of the current document to the right.

It should not matter what resolution it is

This way works just fine for me in CS2 resizing and moving this is broken so either switch to 72dpi and back without sampling or do math work around.

tell application "Adobe Photoshop CS2"
	activate
	set display dialogs to never
	set ruler units of settings to pixel units
	set background color to {class:RGB color, red:255, green:255, blue:255}
	set Doc_Ref to the current document
	tell Doc_Ref
		set Old_Resolution to resolution
		resize image resolution 72 resample method none
		duplicate layer 1 to beginning
		-- set Doc_Height to height
		set Doc_Width to width
		resize canvas width Doc_Width * 2 anchor position middle left
		translate layer 1 delta x Doc_Width as pixels
		adjust layer 1 using desaturate
		resize image resolution Old_Resolution resample method none
	end tell
end tell

I don’t have CS3 but think you can have NO current layers or Multi selected so you may need to test for this first.

Belated thank you Mark
I bodged a workround but yours is far cleaner