capture specific area of screen

I am wondering if it is possible, using applescript to capture an are of the screen by inputting the four corner co-ordinates…
alternatively- how to crop a full screen capture…
i tried this :


tell application "Transmission"
	activate
	set the bounds of the first window to {3, 22, 705, 539}
end tell


do shell script "screencapture /Library/Scripts/CUSTOM/Transmission_stats.pdf"

tell application "Finder"
	set theImage to "screencapture/Library/scripts/CUSTOM/Transmission_stats.pdf"
end tell

tell application "Image Events"
	launch
	set theImageReference to open theImage
	
	crop theImage to dimensions {480, 320}
	
	save
	close
end tell

any help would be greatly appreciated…

Thanks.

Hi geoff,

The code below works for me. Of course you will have to adjust the path value to your requirements:


set pdfpath to "/Users/martin/Desktop/test.pdf"
set qtdpdfpath to quoted form of pdfpath

do shell script "screencapture -t pdf -x  " & qtdpdfpath
do shell script "sips -c 480 320 " & qtdpdfpath & " --out " & qtdpdfpath

THANK YOU. thats great. One last question, is it possible in applescript to convert the file to jpg?

You can work with JPG right from the beginning. Just change the name extension and format used for screencapture accordingly (pdf, jpg, tiff & png):


set pdfpath to "/Users/martin/Desktop/test.jpg"
set qtdpdfpath to quoted form of pdfpath

do shell script "screencapture -t jpg -x  " & qtdpdfpath
do shell script "sips -c 480 320 " & qtdpdfpath & " --out " & qtdpdfpath

ah, of course…sorry bit slow today apparently, thanks.
Is there a ‘solved’ button on these forums?

also - for the curious I was doing this script:


tell application "Transmission"
	activate
	set the bounds of the first window to {419, 288, 1121, 805}
end tell

set jpgpath to "/Library/Scripts/CUSTOM/Transmission_stats.jpg"
set qtdjpgpath to quoted form of jpgpath

do shell script "screencapture -t jpg -x " & qtdjpgpath
do shell script "sips -c 250 500 " & qtdjpgpath & " --out " & qtdjpgpath
tell application "Transmission"
	activate
	get the bounds of the first window
end tell

So now i am able to run this script remotely (via iphone web app - telekinesis) then open up the image (which is now conveniently placed on the screen I ran the script from) and check up on my torrents.

Not that useful, but cool none the less…

Thanks for your help again.