Skip to main content
Inspiring
December 18, 2009
Question

Questions about CFIMAGE

  • December 18, 2009
  • 1 reply
  • 453 views

I'm planning to use CFIMAGE on a website and had a few questions about what would be the most efficient way to do this.  I have a lot of images on some pages, so it's important to load them the most efficient & fastest way possible.

  1. I noticed that by default, the writeToBrowser function displays images as a .png image.  Is there a reason for this?  Does that mean it would be best for my original image to be a .png as well, or would it load just as quickly if I start off with a .jpg file? 
  2. Is there a parameter in the writeToBrowser function to add an alt tag?

Thanks

    This topic has been closed for replies.

    1 reply

    Inspiring
    December 19, 2009

    Hi,

    1. I noticed that by default, the writeToBrowser function displays images as a .png image.  Is there a reason for this?  Does that mean it would be best for my original image to be a .png as well, or would it load just as quickly if I start off with a .jpg file? 

    If you don't specify a value for the "format" attribute (in the <cfimage action="writeToBrowser> tag), it outputs the image in "PNG" format by default, And you want to output in "JPG" format set the format attribute as format="jpg".

    Note : You can't output the image in GIF format if you use the "writeToBrowser" action, and when you try do so, you will only get that in PNG format.

    Is there a parameter in the writeToBrowser function to add an alt tag?

    Yeah.. But you may need to install the ColdFusion 8 - Updater 1 which supports all the image attributes.

    http://www.petefreitag.com/item/670.cfm

    You may also try Ben Nadel's "ImageWriteToBrowserCustom" UDF which can be dowloaded here,

    http://www.bennadel.com/blog/846-Styling-The-ColdFusion-8-WriteToBrowser-CFImage-Output.htm

    HTH

    natg504Author
    Inspiring
    December 21, 2009

    Thanks.  I understand that I can force the image to be displayed as a .jpg, but my question is really

    whether that affects performance.  Will the image take longer to load if I have a jpg -> png rather than png->png or jpg->jpg?

    Is there a way to test whether the update 1 has been installed?  (I don't have access to the server admin)

    Inspiring
    December 21, 2009

    Hi,

    Thanks.  I understand that I can force the image to be displayed as a .jpg, but my question is really

    whether that affects performance.  Will the image take longer to load if I have a jpg -> png rather than png->png or jpg->jpg?

    If you consider rendering your image at a better quality and you are not worried about the size of the image that is being rendered you can opt for "PNG", otherwise choose "JPG".

    Is there a way to test whether the update 1 has been installed?  (I don't have access to the server admin)

    Try <cfdump var="#server#">