• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFEXECUTE Imagemagick

New Here ,
May 02, 2024 May 02, 2024

Copy link to clipboard

Copied

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
 
 
TOPICS
Advanced techniques , Builder , Connector

Views

177

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2024 May 02, 2024

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 02, 2024 May 02, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2024 May 04, 2024

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2024 May 04, 2024

Copy link to clipboard

Copied

Hio BKBK,

Is there anything different in your new code than what I wrote in my code?
I have already written the individual cfexecutes into their own cflock

 

Kindly Regards Thorsten

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2024 May 04, 2024

Copy link to clipboard

Copied

LATEST

Yes, the new code is different because it has, in addition, cflocation within a lock of the same name.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation