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

Detecting Image Width

Explorer ,
Oct 01, 2006 Oct 01, 2006

Copy link to clipboard

Copied

I want to detect the image width so if it is larger than a certain size, it will resize it down to a certain size, otherwise, it will leave it alone. I assume it is a simple cfif statement. The problem I believe I might have is that the file is already on the server.

I want to do this during the output stage on the page.

So if I have
<cfoutput query="thisquery">
<cfif (the width is greater than say 200 px show this image)>
<img src="#img1#" width="200">
<cfelse (for an image less than 200px or whatever the set width is)>
<img src="#img1#">
</cfif>
</cfoutput>
TOPICS
Advanced techniques

Views

545

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
LEGEND ,
Oct 01, 2006 Oct 01, 2006

Copy link to clipboard

Copied

You'll need to use something like the Alagad Image Component to read the
image sizes:

http://www.alagad.com/index.cfm/name-aic

or Massimos tmt_img

http://www.olimpo.ch/tmt/cfc/tmt_img/

http://www.massimocorner.com/

--
Ken Ford
Adobe Community Expert


"weswhite7" <weswhite7@comcast.net> wrote in message
news:efntam$8j3$1@forums.macromedia.com...
>I want to detect the image width so if it is larger than a certain size, it
> will resize it down to a certain size, otherwise, it will leave it alone.
> I
> assume it is a simple cfif statement. The problem I believe I might have
> is
> that the file is already on the server.
>
> I want to do this during the output stage on the page.
>
> So if I have
> <cfoutput query="thisquery">
> <cfif (the width is greater than say 200 px show this image)>
> <img src="#img1#" width="200">
> <cfelse (for an image less than 200px or whatever the set width is)>
> <img src="#img1#">
> </cfif>
> </cfoutput>
>


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
Engaged ,
Oct 01, 2006 Oct 01, 2006

Copy link to clipboard

Copied

you can also check out
http://www.opensourcecf.com/imagecfc/

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
Explorer ,
Oct 01, 2006 Oct 01, 2006

Copy link to clipboard

Copied

Well there is a problem, I can not have custom tags where we are right now. If we got a dedicated server which we may eventually, I might do that. What about doing this and creating a field in the database for the width. I know a guy in the past told me a way to do it on file upload using cffile.width I think. Is that what it is, or is it something different? I could just set that as a variable and place that to the database.

I guess my question now is, how to do it during cffile upload?

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
LEGEND ,
Oct 01, 2006 Oct 01, 2006

Copy link to clipboard

Copied

I don't think you can get the width during upload.

http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000253.htm#3540091

--
Ken Ford
Adobe Community Expert


"weswhite7" <weswhite7@comcast.net> wrote in message
news:efp9ul$p2g$1@forums.macromedia.com...
> Well there is a problem, I can not have custom tags where we are right
> now. If
> we got a dedicated server which we may eventually, I might do that. What
> about
> doing this and creating a field in the database for the width. I know a
> guy in
> the past told me a way to do it on file upload using cffile.width I think.
> Is
> that what it is, or is it something different? I could just set that as a
> variable and place that to the database.
>
> I guess my question now is, how to do it during cffile upload?
>


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
Explorer ,
Oct 01, 2006 Oct 01, 2006

Copy link to clipboard

Copied

Well I am saying right after upload and cffile.serverfile returns you the name, I think you can get the width as well I just do not know the code for it. I know for a fact that you can get the file size because I used to check the size of the file and if it was over the limit I would turn around and delete it right there.

I am thinking I did check for the image dimensions as well to make sure it fit the box it was going in. I just do not remember the code for it.

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
Explorer ,
Oct 01, 2006 Oct 01, 2006

Copy link to clipboard

Copied

Or are there even any cfscripts? I can use those tags and I do use that for a text format.

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
LEGEND ,
Oct 01, 2006 Oct 01, 2006

Copy link to clipboard

Copied

LATEST
http://www.cflib.org/udf.cfm?ID=1019

http://www.cflib.org/codeView.cfm?ID=1019

--
Ken Ford
Adobe Community Expert


"weswhite7" <weswhite7@comcast.net> wrote in message
news:efpbk4$qp6$1@forums.macromedia.com...
> Or are there even any cfscripts? I can use those tags and I do use that
> for a text format.


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