use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
set posixPath to "/Users/shane/Desktop/Sample EPS.ps"
set thisResult to its makeTiffFromEPSAt:posixPath withDPI:300
on makeTiffFromEPSAt:posixPath withDPI:dpi
set posixPath to current application's NSString's stringWithString:posixPath
set destPath to posixPath's stringByDeletingPathExtension()'s stringByAppendingPathExtension:"tif"
# make image representation from file
set oldRep to current application's NSEPSImageRep's imageRepWithContentsOfFile:posixPath
set imageSize to oldRep's |size|()
set theWidth to width of imageSize
set newWidth to theWidth * dpi / 72
set theHeight to height of imageSize
set newHeight to theHeight * dpi / 72
-- make new bitmap the right size
set newRep to (current application's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:newWidth pixelsHigh:newHeight bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(current application's NSDeviceRGBColorSpace) bitmapFormat:(current application's NSAlphaFirstBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
-- store the existing graphics context
current application's NSGraphicsContext's saveGraphicsState()
-- set graphics context to new context based on the new bitmapImageRep
current application's NSGraphicsContext's setCurrentContext:(current application's NSGraphicsContext's graphicsContextWithBitmapImageRep:newRep)
-- draw from old rep into bitmap
oldRep's drawInRect:{origin:{x:0, y:0}, |size|:{width:newWidth, height:newHeight}} fromRect:{origin:{x:0, y:0}, |size|:{width:theWidth, height:theHeight}} operation:(current application's NSCompositeSourceOver) fraction:1.0 respectFlipped:true hints:(missing value)
-- restore graphics state
current application's NSGraphicsContext's restoreGraphicsState()
# extract tiff data
set theData to newRep's representationUsingType:(current application's NSGIFFileType) |properties|:{NSImageCompressionMethod:(current application's NSTIFFCompressionLZW)}
# save to file
theData's writeToFile:destPath atomically:true
end makeTiffFromEPSAt:withDPI: