I'm loading some jpg files and need to know if I can resize the images when I load them? For instance, if the image is 320X240 can I resize it to 180X120? I want to scale the image and make it a thumbnail. Thank you for the help.
Printable View
I'm loading some jpg files and need to know if I can resize the images when I load them? For instance, if the image is 320X240 can I resize it to 180X120? I want to scale the image and make it a thumbnail. Thank you for the help.
you can use the movieclip width and height properties
I'm loading into a clip that I have in the library that is already sized but it doesn't really work. I could try sizing it again with AS once it's attached but I don't think that's going to make a difference
Yeah, I just traced the width of the mc and it give me the width I'm trying to resize to, not the with of the image inside.
well IE is saying the php file doesn't exist...
Yeah, sorry about that. That is another post that I have on a completely unrelated problem. It pertains to what I'm doing but has nothing to do with the size of my pics. My post above explains.
Here's my code if you care to take a gander.
Code:var x:XML = new XML();
x.ignoreWhite = true;
var urls:Array = new Array();
var whatPic:Number;
x.onLoad = function(){
var photos:Array = this.firstChild.childNodes[0].childNodes;//first child is vehicleInfo firstChild.fisrtChild=Vehicle1Pics childNodes are the photo tags
for(i=0; i<photos.length; i++){
var m:MovieClip = _root.createEmptyMovieClip("subV"+i,i);
m._x = 46*(i+1);
m._y = 92*(i+1);
urls.push(photos[i].attributes.url);
m.loadMovie(urls[i]);
};
m._width = 96;
m._height = 72;
holder.loadMovie(urls[0]);
price.text = urls[10];
vehicleMake.text = urls[11];
info.text = unescape(urls[12]);
whatPic = 0;
}
x.load("http://www.webmakerx.net/Images/Sites/Site8783/Document/usedSpecials2.xml");
flash only cares about the path to the picture and the size of the mc it doesn't care about the content of the picture....you have to use the bitmap class to resize the picture by resampleing the pixels otherwise flash will just stretch and distort the image ....when you resize and resample the image its called cropping
Oh, duh! I've recently been playing with the bitmap class with Tweens. Thanks, I'll get this sorted out now!
hey let me know how your progress goes and maybe i can help there are some advanced concepts we can add to your picture resize scripts after we get going ...i've been meaning to do this very thing for awhile now so if you want to work on it with me that would be great i have a few books here that will be helpful ....ask questions and i will try to find the answer no question is too stupid.
that sounds great. Right now I haven't got too far. What I've got going is a major change in how I update pictures for work. I work for a car dealership and we have these used car specials every week that I put out. I take 5 pics of 5 cars, so 25 pics. But then I have to resize all of them in photoshop and make 2 of each so I end up with 50 pics. 25 thumbs and 25 full size. Then I edit an xml sheet to put these pics into my swf that way I don't have to open it. But, I've changed that to get the info through php. When you go to the site the swf gets a php file that reads a directory on the server and then send the pics to flash. It sorts them and puts them on. I'm going to make this very dynamic so it might be a large project to go around. This so far all works. I then only want to have to upload the 25 full size pics, and have flash resize them. Then with that I'll have flash create empty movie clips depending on the amount of pics that need to go in the swf and have them spaced dynamically and load the full size into the holder mc on release. This way I can take 12 pictures of a car if I want and have flash figure out that there are more pics and place them accordingly. Right now it's just too much work to do all that but once I get this done it will be a piece of cake.
Problem of that method is bandwidth. People will be downloading large images when they should be downloading small images.
lollerskates bandwidth is not an issue many websites use large and small photos it all depends on they type of photo being used and how many KB it is.....mneil lets not worry about bandwidth issues right now lets just get things moving with the resize and resample in flash....did you know that flash can upload pictures too? php is not the only way even though php does have its benefits.
if you have a large photo and are displaying it as a fraction of the size, it is a waste of bandwidth. fact.
lollerskates you have included your 2 cents now either help us or move on.
yeah, But I've kind of got that solved. I don't load all 50 pics in at once. In my original model I have 5 swf's, on for each vehicle. I cued(however you spell that) them and only loaded the image as the thumbnail was loaded in. That way the user only loaded what they wanted to see. So, even though this new way is bigger, what I'm planning on doing now is to still only load the images that are needed for that car. I'll load the images one after the other and resize them as they come in to make the thumbnail. Also, I'll add a little delay at the beginning to mask the slowness of the file(a preloader to check for at least 3 loaded images). The users that are interested in the specials I'm assuming will look at every picture of the vehicle. So, I'll preload to a screen with 5 smaller pics of these cars; the user can click the car and it will redirect them to that cars page that has been loading, and as long as there are 3 pics on that page the user will proceed without pause. And, I won't really put 12 pictures of cars up. Plus the full size pics are only about 10k each.
I know flash can do it on its own. But, flash can't read folder contents and urls of pictures, php can. I use flash to load the files that php tells it to. So there is no editing of the swf ever once it's uploaded. Everything is handled dynamically. If I load the picture to the server in the particular folder it appears in the swf automatically. The only thing I have to do for it to work is add a number like 1 2 3 4 5 at the end of the filename so that when flash sorts it it will be in an order that I can predict so that flash knows what page to put it on.
mneil I think your idea and concept are solid and you should really continue to explore resizing pics with flash after you get that code perfected a whole lot of doors and ideas will open for you....pictures are an absolute integrial part of websites....if you want to use php along with your flash by all means feel free to make a hybrid flash site.
Sure, I'll help. What would you like help with? I can help you with the definition of "cropping" - it's not about resizing and resampling, it's about trimming an image. I could also let you know that you need php (or some other server side technology) to read from folders to upload an image. Is there anything else you want help with? A comment like "bandwidth is not an issue" is ridiculous. Not an issue for who?
listen lollerskates i have 1,202 posts and you have 10 i have alot more exsperience and definately know what i'm talking about so post some code that is realted to this project or bugger off
unless you own this forum i would really appreciate it if you would stop telling me to leave. i was pointing out that loading in a large image at a much smaller size pretty much goes against the 'rules' of making websites. i'm not saying people have to abide by these rules but they are there for a reason.
why are you so aggressive?
your number of posts does not give any indication as to the quality of your advice. any idiot can post lots on forums. calm down yeah?
Okay, I've been working on this for a bit now and I think I'll upload a swf for a preview. I've got the resizing working. I've got to clean it up still. And right now I'm reading from xml, which I think I might just keep it that way and use php to update the xml with some fancy flash cms. That way should make the parsing of info a little cleaner and efficient since I'm going to need all the extra speed I can get. What I've got now uploads the files on a blank stage at one size and makes a smaller one underneath at another size. The resampling doesn't seem to be real hard on bandwith but it is definitely cpu intensive. The reason this doesn't take much longer than the way I was doing it before is because I had to load the full images in the other way too. Plus, as I mentioned, my target audience is going to look at all the pictures because of interest.
I understand where you're coming from loller, and I understand the difference between cropping and re-sampling pixels. I'm a designer by profession; I just got into programming awhile ago and have always liked it. So that being said; do you know of any way to trim some of the file size off once it's loaded or as it's resampling. My bitmaps are at 32 ppi and look good there, but of course the thumbs can be smaller, they don't have to look real good anyway. I want to get this done, but I want to do it right, so I need help making a weird method of adding pictures as effecient as possible. Any ideas would help.
Oh, and right now my original pics are 400px wide so I'm resizing each image twice right now, but I won't be in the end, which should help speed this up slightly.
wonderful you are keeping up with me .....the trick is to crop the picture from the middle and resample the picture so that it is clear.....just removing pixels from the center without destroying the image that way you don't cut off and ear as easily ..this is the advanced concept that i was speaking of earlier.
I'm using smoothing right now to keep a clear image.
nice may i have a copy of the code or .fla? so that i can tweak it to suit my needs?
Post back something when you get it doing what you need so I can take a look. This code isn't all mine, I got a lot off of some old forums from actionscript.com
do you know how this xml stuff works in this code i haven't taken the time to learn xml and i need to know how to simply load a single picture that resides in the same folder as the .swf into this movie clip container.
if you don't know how to load in an image from a folder then it sounds as though mneil's project is beyond what you know.
either of these will load in a picture from a folder
Code:var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(mclis);
_root.createEmptyMovieClip("holder_mc", _root.getNextHighestDepth());
_root.mcl.loadClip("your image", _root.holder_mc);
Code:_root.createEmptyMovieClip("holder_mc", _root.getNextHighestDepth());
_root.holder_mc.loadMovie("your image");
Hi, I'm not totally sure what you're wanting to do (sorry). I downloaded your file but can't see it in action without the XML file. Maybe you could post a picture of the original image and another picture of how you want the image to look after flash has finished resizing it?Quote:
Originally Posted by mneil
hi this thread may help with regards to resizing images:
http://board.flashkit.com/board/showthread.php?t=719390
thanks lollerskates that helped me exactly 0% ...i know how to use moviecliploader but I can't seem to make it work with the resize code that mneil uploaded...somehow he is using a freaking xml file which i want to eliminate....how do rewrite the .fla so that it doesn't use the xml i want to use an array to tell it what to resize.
you said "i need to know how to simply load a single picture that resides in the same folder as the .swf into this movie clip container" and i told you how to do that. if that wasn't what you wanted then ask a different question.
first you're talking about a single image, then you are talking about an array - which is it? if you want flash to read the contents of a folder - how do you suppose you are going to do that without server side technology?
ok i can see you need to be brought up to speed so i'm gonna ignore all our previous disagreements and tell you what i plan to do........i plan to store the path to each picture in and array then I want to tell the resize function which picture to load and resize something like.....loadPic = array0[1];.........i know i know not all the code is there to make an array i often don't include all code when writing examples so you have to read into what i post a little bit. ok.
LISTEN!.. all of you..
either get along, or I'll close the thread.. PERIOD!
a couple things I have noted in this thread alone:
1.) post count and time here on FK mean NOTHING!.. absolutely NOTHING!!! If you judge someone on their post count or join date, you have problems, and a severely narrow minded.
2.) NOONE has the right to tell anyone to leave or not post... UNLESS, you are:
a.) a MOD
b.) a super mod
c.) an ADMIN
d.) you have broken one of the FK rules of posting, including (but not limited to) bad langunage, name calling, piracy/warez posting or SPAM!
got it? this goes for ALL of you.
now back on top.....
1.) he is scraping the directory with a PHP script.. to return the file name.. last I checked/spoke with him.. has this changed?
2.) lollerskates (IMHO) posted relavent information, I too woudl advise against any re-sizing of images through Flash..bitmap class or not... it would take half the time and effort to have my original 25 images.. run a 1 button batch script in Phtotoshop that re-sizes them ALL in seconds... no-resize garbage, no image quality degradation..etc..etc..
HOWEVER, if it something you want to explore.. by all means go ahead.. IMHO, just inst the fastest/better approach.
on a side note: calmchess, maybe 7you should calm down somewhat... from your posts it seems that you are NOT that well informed on certain methods/practices...so listening instead of fighting MAY help you.
If you want to do it YOUR way...thats fine... and in the end he can choose to follow your way or the advice of others..
I think in the end:
1.) there will be NO XML.. as the PHP script will just generate the file names back to the movie using a flashVar that he will have to split to get all the files names from.
2.) I still say re-sizing in flash is overkill..
again, FIGHT NICE,... or thread will be closed.. and possible BANS handed out if you guys wanna keep it up.
:)
take care
Alright guys, I've been gone all weekend. Whispers is correct. There will be no xml in the end, it will all be done through php. I'll post some more later with the xml so you can see exactly how I'm doing it for now.
Whispers... THANK YOU!
Also, it has not changed. I may not do it with the bitmap resize and just keep to my original method but this is interesting for me to play with. I want to know your reasons for saying it is overkill that way I can be informed on this. I do not really know what it is exactly I'm doing, that's why I posted and thank you very much for your help. Also, I mentioned above that I used smoothing on the loaded bitmaps. The image quality for my particular pictures come out looking good this way. ie: there is no noticable deterioration in picture quality. Thank everyone again for their help and interest in my question.
hi..
I have read that checking the "ALLOW SMOOTH" helps when you TWEEN your images so NOT to be so pixelated..
I also think taking a LARGE image and re-sizing it in Flash is NEVER the way to go... I am a firm believer that you do your IMAGE editing outside of Flash previous to loading using them in your project... (there are certain applications where you WOULD want to manipulate your image in Flash though.. I dont want it to be taken that way..but for most cases..no)
the bottom line is:
there are always more than way way to accomplish something...
If you want to learn ALL the ways.. awesome.. your just that more informed and ready to handle a variety of situations....
however there are certain, better approaches to tackle certain problems..
whatever works for you in the end is what you should use, if several things work, use the best method for the project to make it the most expandable, scalable application it can be...
it would be MORE work.. for the project to have to taken an image, copy it, re-sample it, shirnk it, and then use that to load/display (whatever) hen it will be for a regular load call to load a (smaller) pre-made version of the bigger image..
again, a simple one button push in Photoshop can be set up to point to a folder and re-size to whatever size you need them to be..
I'll consider all of this thank you.
I did read that allow smoothing helps when tweening too. But, I also noticed and read that when you use flash to resample the bitmap and use bitmapData.draw() to manipulate the size that the image will both "shift" pixels and can either band or tear. The image shifts about 2px up and to the left no matter what, unless you scale it slightly larger than you want and then move the x and y back over. Also, the colors tend to change slightly and the edges seem to diffuse. Dynamically smoothing the images takes care of most of these problems.
I noticed these problems when I first tried manipulating the size in flash. I only found someone else's solution to the problem was to use smoothing.
Just thought I'd throw that info out there. I don't know how much anyone has really played with doing this.
:thumbsup: good things to know. :)
mneil its good to see you are still intrested hey think you could upload a zip file that has the .fla .xml and an example picture in it so that i can see how all the files work togeather....i haven't had any luck with making the first .fla you uploaded work.
Hi all,
I'm currently working on a small gallery for a client. Still a work in progress, but it seems the resize code i use (copying the BitmapData to a temp var, then draw() it, then attach with smoothing true) gives pretty good results.
Here's the temp. file url:
http://www.genevieveparis.com/client...iemacleod.html
resize the window or go fullscreen on/off
gparis
Thanks gparis. That is exactly the method that I'm using. I like the look of it, and how it all loads in. I thought I uploaded my files on this thread but I guess not. I've got it all working but I didn't take the files home with me. I'll upload tommorrow so calmchess and anyone else who wants to can see. I do not have the interface yet like yours does but it will show people how to get the files in and resize them.
It runs pretty good on a cable connection. I ran it with sloppy at 56k to see how it would work; since I haven't really tested my own, and it took 20-30 seconds to see the first image. Have you tested speed yet gparis, and what did you get? Also, might I ask what the file size is of each of those pics? Oh, and I know your still working it, but I'm assuming a preloader too right? That's a pretty dumb question I know but I'm asking because I'm wondering if it will show loaded before the bitmapData.draw() has the chance to actually render the picture on slower processors; and if so, what kind of wait?
Again, thanks for all the interest guys.
gparis-
that is some nice looking re-sampling you got going on.. :)
this is a perfect example of where (IMHO) re-sample/re-sizing an IMAGE is useful/needed.
for a LARGE version of the images to still be used for the 'content' :)
now Im going to have to play with the class/code :)
What i also like with that method, is that when you click on the thumbnail, there is no "image loading" at all, they are all already loaded. There is only a fast "copy/paste". For that reason i used an animation for the loading of the thumbs so the whole loading process doesn't feel too long.(these thumbs are the actual big pictures scaled, copied, then pasted in the bigger container to the available size and at ratio)
gparis