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

displaying images at a fraction of the size

Participant ,
Jul 14, 2008 Jul 14, 2008
This may not be a coldfusion question but I'm going to ask it here anyway because cfml developers are the smartest. :)

I have a table that stores images paths and in my cfm file I pull the path and display the image. What I want to do is take that image and display it at a fraction of the size without harcoding the height and width parts of the img tag. Can I do this? Is there a way to detect the width and height of an image before displaying it?

Thanks
477
Translate
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
LEGEND ,
Jul 14, 2008 Jul 14, 2008
Here is one way:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_h-im_39.html#5171309

--
Ken Ford
Adobe Community Expert - Dreamweaver/ColdFusion
Fordwebs, LLC
http://www.fordwebs.com


"idesdema" <webforumsuser@macromedia.com> wrote in message news:g5gn1h$sr3$1@forums.macromedia.com...
> This may not be a coldfusion question but I'm going to ask it here anyway
> because cfml developers are the smartest. :)
>
> I have a table that stores images paths and in my cfm file I pull the path and
> display the image. What I want to do is take that image and display it at a
> fraction of the size without harcoding the height and width parts of the img
> tag. Can I do this? Is there a way to detect the width and height of an image
> before displaying it?
>
> Thanks
>
Translate
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
Participant ,
Jul 17, 2008 Jul 17, 2008
Nice. I had this working before but now am confused. I keep getting this result when I output my variable

coldfusion.image.Image@1aa15ab

I am trying to resize and overwrite an image.

<cffile action="upload" filefield="photo1" destination="mypath" nameconflict="makeunique">

<cfset upload_photo = #file.ServerFile#>

<cfimage action="info" source="C:/mypath/#upload_photo#" structname="image_size">

<cfimage action="resize" height="5%" width="5%" source="C:/mypath/#upload_photo#" destination="C:/mypath/#upload_photo#" name="resized_image" overwrite="yes">

<cfoutput>#resized_image#</cfoutput>

Translate
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
Participant ,
Jul 17, 2008 Jul 17, 2008
Ok I have it working. However, now there is a new issue. Images that have a space in the name or a %20 in the name are being written to the server, but then won't display???? I see it there in the directory, and then when I put the absolute URL into the browser it won't display. Anyone know what's going on?

Do I need to do URLEncodedFormat on images???
Translate
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
Valorous Hero ,
Jul 17, 2008 Jul 17, 2008
> I put the absolute URL into the browser it won't display.
> Do I need to do URLEncodedFormat on images???

No. You may however need to encode a URL that points to an image. For example:
http://www.yourcompany.com/images/logo with a space in it.gif

However, I agree with Ken Ford. IMO, a safer course of action would be to remove spaces, and other problem characters, from the file name altogether.

Translate
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
LEGEND ,
Jul 17, 2008 Jul 17, 2008
Spaces in folder or file names for web stuff is a very bad idea.

Don't know the answer to you question though, sorry.

--
Ken Ford
Adobe Community Expert - Dreamweaver/ColdFusion
Fordwebs, LLC
http://www.fordwebs.com


"idesdema" <webforumsuser@macromedia.com> wrote in message news:g5nv0a$3tf$1@forums.macromedia.com...
> Ok I have it working. However, now there is a new issue. Images that have a
> space in the name or a %20 in the name are being written to the server, but
> then won't display???? I see it there in the directory, and then when I put
> the absolute URL into the browser it won't display. Anyone know what's going
> on?
>
> Do I need to do URLEncodedFormat on images???
>
Translate
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
Participant ,
Jul 17, 2008 Jul 17, 2008
I totally agree about avoiding spaces and strange characters in filenames but the problem is that other people are uploading these files so I don't have any control.

The problem image is named like this: my%20image%20yay.gif

Translate
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
Valorous Hero ,
Jul 17, 2008 Jul 17, 2008
idesdema wrote:
> but the problem is that other people are uploading these files
> so I don't have any control.

Well, if your code handles the actual upload, then you have have control over the final names of the files on the server. Simply upload the files, then rename them however you want.


Translate
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
Valorous Hero ,
Jul 17, 2008 Jul 17, 2008
idesdema wrote:
> The problem image is named like this: my%20image%20yay.gif

Did you try using URLEncodedFormat when you generate the image URL?

Translate
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
Participant ,
Jul 17, 2008 Jul 17, 2008
LATEST
I can rename... I didn't think of that actually even though I'm manipulating the images already anyway. It actually makes sense to rename them too so I can name them in the order they were uploaded. Thanks cfSearching.
Translate
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