Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alagad Image Component file size? 1

Status
Not open for further replies.

JamesManke

Programmer
Jul 1, 2004
54
CA
I recently started using Alagad Image Component and to my surprise found that once reading an image and then writing it, the file size was larger than the original. Here is am example below...

<cfset myImage.readImage("my_path\test.jpg") />
<cfset myImage.writeImage("my_path\image.jpg", "jpg") />

The file size on the original image was 16.79kb
and the one Image Component created was 33.67kb.

I even tried this...

<cfset myImage.readImage("my_path\test.jpg") />
<cfset myImage.writeImage("my_path\image.jpg", "jpg", "50") />

and the file size was still larger and crappier quality!

Help me on this one, this is a major problem in my opinion for fast loading pages!
Any ideas or comments?

Thanks
 
I'm not familiar with Alagad Image Component, so I'm not entirely sure what you're trying to do. Could you upload the image with cffile and then just display it?
 

" so I'm not entirely sure what you're trying to do "

I am tring to resize an image with out having the image be larger in file size than the original. For obvious reasons.

Thanks for having a look at this for me,

James
 
i use alagad and never have had a problem with it... looks like you're not either. top file is 1228.63k and bottom resized is 37.96k just like wantstolearncfm says.

<cfset myImage.writeImage("my_path\image.jpg", "jpg", "50") />

and the file size was still larger and crappier quality!
no kidding,
compressing 50% isn't just like "zipping" the image, you take some quality away, that's the trade. compressing it 50% is going to make it look pretty crappy. I doubt the file size was bigger too seeing as how you think 37k is bigger than 1228k...

Here is the Image after Image Component has resized it to 100px and compression down to 10 !!!
last i checked 100 was a lot smaller than 300, which is what the current image width is. further more if you compressed it "down to ten" meaning 90% compression... That's some pretty darn good quality!!! Although I'm sure you didn't get that right either.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
My appologies, I was playing with that test file and didn't change it back. It is now back to my original question.

Top image is width is 240 and bottom one is 100, yet the bottom image is larger in file size.

Any ideas???
 
ah, that's better. :)

The only thing i can offer is the original is already pretty small... try to compress the origial to about 80% just 20% makes a huge differance. I had an original in fireworks that was 700k. compressed it by 20% and the file size went down to 200k and lost very little quality.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
I justt recieved an email from Alagad, the makers of this tag, and they stated that they were aware of this issue and that it would be fixed in future releases. Buit what good does that do me right now is the question! Is any one aware of any other tags that compress images other than ImageMagicK?

ps - Thanks bombboy - good point.
 
how are you creating the thumbnails? as the page loads?

CF Image componants are differant than other languages because the other languages create the image and put it right in memory. CF can't do that. when you create the thumbnail put it in a different folder then when you display the thumb look in the thumb folder. You only have to create it once, when the image is uploaded. that will speed you up. I was doing it "on the fly" when i first started using it and it was horidly slow. now i create the thumb when they upload and it works great.

is the largest example of this.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
You say "CF Image componants are differant than other languages because the other languages create the image and put it right in memory."
I say "CF Image Component (the tag) does upload the image directly into memory."

The thumbnail images are being created and stored in a image folder (in memory). They are not be created on the fly so to speak. I have set up my script to email me every time the adminstrator uploads a new picture and I then go in and optimize it using a batch in Photoshop. I realize this isn't the most dynamic way about it - BUT - it seems to be my only option at this moment untill Alagad releases version 2.0 with this fix. They say that this fix will be out soon, but no promises of course.

What I am really looking for is an alternative to me having to go in and optimize images every time they upload new images. As you could imagine, this could be a pain in the A$$. There must be a tag out there that can optimize images that already reside in a folder other than ImageMagicK and if not why the heck are they offering ImageMagicK for free??

 
it stores it in an image folder, yes you are correct...
in memory, no you are incorrect. it saves it to the hard drive. You only have to create the thumbnail one time. if you have a page that runs displays 20 thumbs and each thumb is created "on the fly" at that moment in time yes it's going to be slow. When you upload the image, run the componant. it will save the thumb in the folder you tell it to, along with all the other thumbs you've created. to show the thumb you simply
Code:
<img src = "[URL unfurl="true"]http://www.yoursite.com/images/thumbs/image.jpg">[/URL]

you shouldn't run the componant each time you display the image.

here's how i do it.

1) upload image
2) run componant in same page as your "cffile action = upload" [ in my case, this saves the original to /images and the thumb to images/thumbs]
3) use the image thumbnail in the page, make it a hyperlink to the original.
Code:
<a href = "[URL unfurl="true"]http://www.yoursite.com/images/image.jpg"[/URL]
<img src = "[URL unfurl="true"]http://www.yoursite.com/images/thumbs/image.jpg"></a>[/URL]

I also have the option for users to change thumbnail sizes.

1) delete all files in /images/thumbs
2) loop through all images in /images run componant on each image saving the new thumb with the new width settings to /image/thumbs
3) use in same as step 3 above.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
when i said
"CF Image componants are differant than other languages because the other languages create the image and put it right in memory."
i mean it never saves the file in a place you can access it later. in fact there are no disk IO's the thumbnail never gets any further than memory.

example. here is an asp componant that creates thumbs... notice the thumb location, it doesn't point to an actual image. the thumb doesn't exist on the server when it is truly done "on the fly"
Code:
[URL unfurl="true"]http://www.mydomain.com/store/thumb.asp?width=100&path=C:\full/path/to/original/file/which/is/mybigimage.JPG[/URL]

this is where CF contrasts because cf can't do this. it HAS to save it to the hard drive first, no choice, just the way CF is. In a way this is a huge bennifet. you only have to run the componant once, not each time the image is shown.

have you tried to compress the image to 80% of original?

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
I do have to admit... I can't see why that thumb is as big as it is anyway. in the link i posted above the thumbs are 150px wide and the largest file size is only in the 7k area... I'd have to dig through my code but i don't think i'm even doing any compressing.

odd you'd get a file size that large. did they say what causes that in the email?

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
I have tried compressing with Image Component. I even tried 1% and the file was still larger than the original, now that one gets me!

They did not mention why, but I will write back and find out and get back to you as soon as I get a reply.

In the mean time, if you happen to run by the code, would be a great help if I could view it. No worries if you don't.

Thanks BombBoy
 
I'll take a look for it tonight when i get home tonight. I'll try and have it posted around 4pm est.

hope it helps.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Code:
			<cfobject component="Image" name="staffImage">
			<cfset staffImage = createObject("component", "Image")>
			<cfset staffImage.readImage('c:\full\path\' & cffile.serverFile)>
			<cfset iWidth = staffImage.getWidth()>
			<cfset iHeight = staffImage.getHeight()>
			<cfset newHeight = iHeight/(iWidth/qImageInfo.ImageWidth)>
			<cfset staffImage.scalePixels(qImageInfo.ImageWidth, newHeight)>
			<cfset staffImage.writeImage('c:\full\path\' & cffile.serverFile, "jpg")>

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Thanks BombBoy:) Certainly did help! I'll let you know when I get a response from Aligad, still nothing. Took them a few days last time I emailed them. Have a good one.
 
is that any different than you were doing?

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top