Skip to main content
New Participant
May 2, 2024
Question

CFEXECUTE Imagemagick

  • May 2, 2024
  • 1 reply
  • 536 views

Hi all.

I have a PDF file with two pages. Here I generate two individual GIF files using Imagemagick/Ghostscript convert. everything works. An image is inserted on the second page of the PDF. If the image has a higher resolution, i.e. the file format is larger, then Coldfusion will not generate the second convert correctly. only one image is generated. It works manually in the command line on the server. So the PDF is fine. I also played shcon with the timeout and set it higher. But that doesn't help either. Does somebody has any idea? A solution?

here my code:

<cfexecute  name="convert" arguments='convert -resize 400 -interlace none -layers flatten -density 200 -quality 40 "#temp_vorschau#/pdf/#vorschau_bild#.pdf[0]" "#temp_vorschau#/pdf/#vorschau_bild#_1.gif"' timeout="20">
</cfexecute>

<cfexecute  name="convert" arguments='convert -resize 400 -interlace none -layers flatten -density 200 -quality 40 "#temp_vorschau#/pdf/#vorschau_bild#.pdf[1]" "#temp_vorschau#/pdf/#vorschau_bild#_2.gif"' timeout="20">
</cfexecute>

 

Kindly regards.
Thorsten
 
 
This topic has been closed for replies.

1 reply

BKBK
Adobe Expert
May 2, 2024

What you observe might be the result of race conditions between the two processes. To test this hypothesis, use a named lock.

 

For example,

<!--- Use of named lock of exclusive type. This is to ensure that the second cfexcute runs only after the first has completed. --->
<cflock timeout="30" name="imageMagickConvertLock" type="exclusive" throwontimeout="true">
	<cfexecute  name="convert" arguments='convert -resize 400 -interlace none -layers flatten -density 200 -quality 40 "#temp_vorschau#/pdf/#vorschau_bild#.pdf[0]" "#temp_vorschau#/pdf/#vorschau_bild#_1.gif"' timeout="20">
	</cfexecute>
</cflock>

<cflock timeout="30" name="imageMagickConvertLock" type="exclusive" throwontimeout="true">
	<cfexecute  name="convert" arguments='convert -resize 400 -interlace none -layers flatten -density 200 -quality 40 "#temp_vorschau#/pdf/#vorschau_bild#.pdf[1]" "#temp_vorschau#/pdf/#vorschau_bild#_2.gif"' timeout="20">
	</cfexecute>
</cflock>
New Participant
May 2, 2024

Hi BKBK,

 thanks for the tip. I tried it, but unfortunately it doesn't work. By the way, the second one is not executed. But it doesn't seem to be because they aren't executed one after the other, but because coldfusion aborts the page too quickly, so it switches to cflocation at the end too quickly. If I try to create the second page alone, it doesn't generate an image even with the larger file.

 

Kindly Regards Thorsten

BKBK
Adobe Expert
May 4, 2024

I was of course unaware of the cflocation code. What about the following test? 
(The hypothesis remains the same: sequential execution)

<!--- Use of named lock of exclusive type. This is to ensure that the locked code blocks run one after the other. --->
<cflock timeout="30" name="imageMagickConvertLock" type="exclusive" throwontimeout="true">
	<cfexecute >
	</cfexecute>
</cflock>

<cflock timeout="30" name="imageMagickConvertLock" type="exclusive" throwontimeout="true">
	<cfexecute >
	</cfexecute>
</cflock>

<cflock timeout="30" name="imageMagickConvertLock" type="exclusive" throwontimeout="true">
	<cflocation >
</cflock>