TIFFRepresentation slowness

I wrote a script that crops PDFs that contain images, and it can be found in post 3 of:

https://macscripter.net/viewtopic.php?pid=211623#p211623

The script generally works as I want, but it is very slow, and one line that appears problematic is in the cropImage handler:

set theData to theImage's TIFFRepresentation()

I looked at the TIFFRepresentation documentation and it contains the following:

So, the thought occurred to me that converting a PDF to a TIFF may simply take some time. However, I wondered if a forum member might look at that handler to see if anything is amiss. Thanks for the help.

Depending on the PDF, and the resolution, creating a TIFF bitmaap can take some time.

@Peavine

I’m little curious why do you like to convert PDF to TIFF.

The greatest point why PDF is superior to many other format is… it include vector format.
If the PDF data include vector data it will be lost in the TIFF format (Raster)

If that is not the case, I would try Core Image instead. (Its fast)

Thanks Shane and Fredrik71 for looking at my script. I appreciate it.

Edit: October 30, 2022. I was unable to get the script to work well and deleted it.