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.

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.