0

Found posts with PDFs to improve the quality but not with images. This is first time working with images and apologize if it is duplicate or silly question.

Have an image with high resolution, adding text to image using x and y coordinates. Final image loses its resolution.

Goal: Keeping the image resolution intact, final image will have custom text and add custom images like electronic signature, custom text image to exiting image. I'm stuck at even keeping resolution after adding custom text. Didn't even made an attempt to add image.

Coldfusion version: 2018 standard

Image properties from coldfusion function before changes

coldfusion-properties

Image properties from actual image

image-properties

Final image quality

final-image-properties

<cfoutput><cfscript>

    variables.string = "test string";

    variables.dupImage = ImageNew("test.jpg");

    ImageResize(variables.dupImage,800,600);

    ImageScaleToFit(variables.dupImage,800,600);

    ImageSetDrawingColor(variables.dupImage,"black");

    variables.attributeCollect = {};

    variables.attributeCollect["font"] = "arial";

    variables.attributeCollect["size"] = 17;

    variables.attributeCollect["style"] = "bold";

    //ImageDrawText(variables.dupImage, variables.string, 115, 190,variables.attributeCollect);

    variables.dupImage.drawText(variables.string, 115, 220,variables.attributeCollect);

    //ImageScaleToFit(variables.dupImage,3300,"");

</cfscript></cfoutput>

<cfimage source="#variables.dupImage#" action="writeToBrowser">
Miguel-F
  • 13,450
  • 6
  • 38
  • 63
Ginger
  • 11
  • 1
  • I'm unable to provide any solution using solely CFML, but we generate PDF reports with lots of hi-res photos using ColdFusion (er, at least the HTML is generated using CF). We use HTML5 & CSS3 to add opacity & text overlays to existing images (w/o any image modification) and use SVG for logos & signatures. Our workaround, since CF8, has been to use CFExecute to use WKHTMLTOPDF (opensource). This is necessary because CFDocument's iText is very outdated and doesn't support modern HTML5 or CSS3. (We also use CFExecute w/GraphicsMagick for image modifications.) – James Moberg Dec 10 '21 at 17:15
  • Maybe I'm missing something, but what I'm seeing is that it's your code that is changing the resolution of the image: ImageResize(variables.dupImage,800,600); ImageScaleToFit(variables.dupImage,800,600); – CFMLBread Dec 21 '21 at 15:09
  • If I resize the image, does it lose its resolution? I was under the impression that it will somehow keep the resolution with respect to the sizing. So if I do ImageResize, it will not guarantee image resolution correct? – Ginger Dec 22 '21 at 17:12

0 Answers0