How can I display a JPG image so that a very low resolution displays first? - html

I've noticed that on some sites, a very low resolution version of an image gets displayed underneath the final version before it's done loading, to give the impression that the page is loading faster. How is this done?

This is called progressive JPEG. When you save a picture using a tool like Photoshop you need to specify you want to use this JPEG flavor.
I've found this Photoshop "Save for Web" dialog sample where you will find the whole Progressive option enabled:

What you are asking for depends upon the decoder and display software used. As noted, it occurs in progressive JPEG images. In that type of JPEG, the coefficients are broken down into separate scans.
The decode then needs to update the image in between decoding scans rather than just at the end of the image.
There was more need for this in the days of dial up modems. Unless the image is really large, it is usually faster just to wait and display the whole image.
If you are programming, the display software you use may have an option to update after scans.
Most libraries now use a model where you decode an image file stream into a generic image buffer. Then you display the image buffer. In this model, there generally is no place to display the images on the fly.
In short, you enable this by creating progressive JPEG images. Whether the image displays fading in dependents entire on what is used to display the image.

As an alternative, you can batch optimize all your images using the ImageMagick's convert command like this:
convert -strip -interlace plane input.jpg output.jpg
You can use these other options instead of plane.
Or just prefix the output's filename with PJPEG
convert -strip input.jpg PJPEG:output.jpg
Along with a proper file search or filename expansion (e.g.):
for i in images/*; do
# Your conversion command
done
The strip option is for stripping any profiles or comments, to make the conversion "cleaner". You may also want to set the -quality option to reduce the quality loss.

Related

Save picture of current screen to disk AS3

I want to add a button to my flash game (AS3) and on click it saves a picture of the current users whole screen and saves it to pictures/disk automatically, but I don't know how to do that, I know how to add the button to the UI and add a click event and all that, just need to know how to make it save a picture of the current screen to disk (doesn't have to be just the flash screen, can be the WHOLE screen of the users pc, either way works!)
I was on my way writing you the answer but I found this post have a better explaination: Is it possible to capture the screen and save the image in actionscript 3?
"Yes, it's possible.
Draw some display object to a BitmapData (the stage, for example) and crop it if neccesary (the second param of BitmapData::draw will help you out here).
Then, convert the raw pixel data to JPEG or PNG using some encoder. I'm sure up to this point, this is what those tutorials will explain you how to do.
Now, the third step is different but simple enough. Instead of sending the image data to a server side script, use a FileReference object. Since Flash Player 10, it has a method called save, that prompts the user to save a file locally.
Since this is a desktop app, you could also make it an AIR app. This will give more direct access to the file system and other features, in case you need them."

Animate shapes / smart objects in PSD file using data/variable csv input

I'm creating a data infographic in Photoshop that inputs 'strengths / weaknesses' from a .csv file in Excel. The only thing I'd like to have is the bars that signal strength/weaknesses to adjust to the data in the csv (e.g. get longer/shorter).
To make it more clear-
Student test scores > .csv file > .psd graphic variables > if A1 = >80%, A1 psd graphic is bigger.
Essentially, I don't want to have to use illustrator to actually 'animate' the graphics. I'm wondering if there's an easier way to have flexible moving graphics per every different .csv data variable.
Would it be easier to just set each graphic itself as a pixel variable that changes? I'm hoping not. Solutions? Anyone have a script for something like this?
A script would be the best answer to your task, if you want to avoid a photoshop variable per pixel graphic.
I am mostly experienced with variable data using Illustrator, but I believe same can be accomplished with photoshop. In your case, variables would be wholly unnecessary, as you'll simply need a script which changes the drawing of your artwork based on CSV data. For example, you can have pixel or path layers named by column headers, and the script would draw or change the path shape according to the data. To get help with such a custom script, you may reach out in the Adobe Scripting forums.

as3 air convert sequence of bitmaps to flv

It's posible convert an image sequence (jpg, png) to .flv (or .mp4 instead), using AS3/AIR?
I'm developing an app. This app must record video on an Android tablet.
As the "CameraUI" class doesn't permit to put images/design over the camera capture, and I need to overlay branded design,
I'm trying to save a sequence of bitmaps using this Starling extension (Using this extension I can overlay desing and it's manage a good performance).
My idea is take the generated image sequence, convert it to video, and then to delete the original bitmap files.
Any idea?
Thanks.
Yes this is possible. FLV is an open format. Easiest way is to create raw flv. Otherwise you need to search for the proper compression (there are libraries online).
For the first one, there are a few very old posts, but I think the idea is the same. Few can be found here:
http://www.zeropointnine.com/blog/simpleflvwriteras-as3-class-to-create-flvs/
http://www.joristimmerman.be/wordpress/2008/12/18/flvrecorder-record-to-flv-using-air/
Try to search for 'flv recorder'. There are few out, even with compression and audio.

AS3 - Using sprite sheets to optimize my games

So, I'm trying to make my flash "games" run more smoothly. I am using individual PNG files for each of my objects in order to create player animations.
I've heard from some places that using individual files like that is bad.
I heard about using sprite sheets in order to compress data and reduce memory usage.
Maybe I have it wrong, but is there a way to merge all of my PNG images (with transparency) together in such a way that flash can continue to use the images individually?
I am really looking for ways to make my programs run more smoothly in order to be able to have lots of images on screen without much lag. Any ideas on how I can make things run better?
Here is an example of a tile based game I'm trying to make that is having serious lag issues.
TexturePacker allows merge png files. It generates two files: png and config file. Png is just merged images and config file is txt file which you can load into your swf, parse and demerge your images using it. Config could be in various formats for different game engines.
Using Photoshop or similar software you would combine all of the animations frames into one file. The size and shape of the file can be whatever you want, but each of the 'frames' should be the same size, in the same order and with no space between them. For example, lets say each frame is 25x25px, your walk animation is 10 frames and you want the final .png to be one long strip. You would make a new .png with the dimensions of either 250X25 or 25X250 and then insert all of your frames into that one file in the order of the animation. It's up to you if you want to embed these as display object or files that get loaded, but once you have them you just need to use BitmapData to break up the input file into new BitmapData objects and then display them as needed. Going one step further, lets say that most if not all characters have a walk animation and an action animation, you would make a single class to deal with loading character animations and the first row of the image file would be the walk animation and the second would be the action animation.

how to create gif animation from a stack of jpgs

I have around 200 jpg images. I need to stack them so that i can convert them into a simple animated gif image. Are there any free tools available to do that job? My os is windows.
I'm not so bothered about the quality of the output.
Try using ImageMagick's convert utility. I have used it to create animated gifs from a set of images (in any format) in the past.
Use the command
convert -delay 20 -loop 0 *.jpg animated.gif
Might want to look at GiftedMotion: http://www.onyxbits.de/giftedmotion
In theory this would work
ffmpeg -f image2 -i image%d.jpg video.avi
ffmpeg -i video.avi -pix_fmt rgb24 -loop_output 0 out.gif
If you'd like a flexible on-line solution, I just used GIFmaker.me and it worked great. It lets you change the frame order, change the size, set the speed, and set the repeat cycles. You can view the animated GIF and download it when you're finished.
Edit: I just used another on-line tool that GIFmaker refers to on their site. GIFcreator is even more flexible, letting you duplicate frames, change the delay for each frame, remove frames, and reverse frames. It also has a more flexible resize capability.
ImageJ and FIJI provide a powerful GUI for doing this is (FIJI is a re-package of ImageJ that also includes some widely used plugins). These powerful (but free!) programs may be overkill, but depending on your needs this may be the way to go, since this is a somewhat common and crucial task for biologists.
Also FIJI can open a large array of different image types, can save to GIF or AVI, and it is very easily scriptable (insternally with in Python or Java) for automating custom tasks etc.
Step-by-step instructions (from Here and Here) are as follows:
Put your images in a folder, and name them in sequence (eg. make sure they
open alphabetically in the right order, perhaps by adding the
desired frame numbers to the start of the filenames).
(On MacOS, this automator action could help)
In FIJI, Select `File > Import > Image Sequence..."
Choose your folder, and then any options (eg. scaling the images)
Preview the video with the Play button in the resulting window's
corner.
To change the frame rate, choose Image > Stacks > Animation > Animation Options...
Select File > Save As > Animated GIF... or AVI... and you're done.
For GIF you can choose the delay between frames (ie. frame rate), and looping option. For AVI you can choose the frame rate.