I am working on an application that are loaded with large png images.
I started to optimize the app performance by reducing the size of each image to it's original size in phone.
I am using adobe photoshop . I was wondered how would be better to output the image file ? save it like normal or use "save for web" and compress it to PNG-8 or PNG-24 .
what do you advice ?
Try to use some of compress tools like http://tinypng.com or http://compressor.io, android studio has bundled some image optimization, if you want to know more watch Google I/O session about it.
http://youtu.be/r_LpCi6DQME
I am creating one application which downloads the images in base64 string format and save it in an image file while downloading data.
My application is available on two platforms: iOS/Android and PC/Mac
The problem is when I downloading the images and saving those on disk I am getting a size difference. In mobile it is downloading the exact size which I have uploaded but on my mac its size is greater than the actual size. Why the size of image in mac is greater than that of actual size downloaded?
in some of operating system maybe file size were difference, and its not problem if, for example your images view correctly.
I have observed that if I use
ByteArrayInputStream and Bufferred Image and ImageIO
class then it is saving the image in high resolution. Now I am using the class
FileOutputStream
to write the content in file. Its keeping the size same as uploaded.
I have an application where users can upload images.
This images are usually taken directly from cameras and in 1mb sizes or more.
May I know what is the standard way of compressing this images before saving them to database as BLOB?
The images stored in database are just for viewing, there is no requirement to edit the image.
I have read this:
Compress Image before Saving to disk in Java
But I am wondering there are more standard ways so that the system can be more maintainable.
some codes and links will be greatly appreciated +1
Hi I am trying to download some images from the server, and I won't save them to the SD card because I want them to be gone when the application finishes. Therefore I want to store them in an array of bitmaps. Is this feasible? My largest image would be about 1000X1086 and there would be about 30-40 of them.
No. A bitmap is stored in memory as uncompressed bytes. A 1000x1086 full color bitmap is about 4MB. Most phones allow an app to use 16-40 MB max, and that includes built in resources. You're over by a factor of 10.
I'm using Universal Image Loader. You can save the images only in memory and clear it when you exit.
Here are all options for download images.
https://github.com/nostra13/Android-Universal-Image-Loader
You have an option... which ain't built in phone memory dependent...
You can save the images in the memory card and delete when the app finishes itself...
This is a really elegant method...
I need to download images that are very large 5mb+.
I am aware of scaling the image before displaying it to save phone memory but the problem of downloading a large image still remains.
How can I download, say, a 50% scaled down version of an image rather than downloading a full image then scaling it?
It must be supported by the server from which you download.
If the server is not yours, you need to look up that server's documentation (or reverse-engineer).
If the server is yours, it depends on the used technology. Look up an image manipulation library for that particular server-side technology you are using.
in case of imgur.com,
look here: http://api.imgur.com/
Imgur lets you make 500 calls per hour per IP, or 1000 if you are registered. Uploads count tenfold.
The metadata about an image is documented here: http://api.imgur.com/resources_anon#image_hash . Access either api.imgur.com/2/image/[hash].xml or api.imgur.com/2/image/[hash].json, and pick either image.links.small_square (90x90) or image.links.large_thumbnail (?x640) from the response. Note that imgur also generates thumbnails (160x160) for its home page. URLs for these seem to be i.imgur.com/[hash]b.jpg
The link to the large image is i.imgur.com/[hash].jpg, so if your link is http://i.imgur.com/xDpEF.jpg or http://imgur.com/xDpEF, then xDpEF is the hash you need.
It is NOT possible to download a scaled down version of some image when the web server does not provide a scaled down version.
You'll need to scale them in the web/on the server, where you host them. So the question is not java/android, but on the webserver, and depends on it.
You can't, unless your server supports scaling down the image before you download it. If the server doesn't have that option, your best option is to scale it down while you read the image from the stream, using BitmapFactory.Options inSampleSize.
Sir it is impossible because if you are downloading it from any server then server must have the scaled image in many forms like 50% scale or 25% scaled. So it is possible only when the server is maintained by you from where you are downloading the image and at backend you have provided some method to scale the image.
If you are downloading the image from any server then is is not possible to get scaled image from server without any backend procedure to scale image.
You will need to download the image to a file, then use BitmapFactory with BitmapFactory.Options to determine the size of the image. From the image size, calculate how much you want to scale it, and again use BitmapFactory (with Options) to load a scaled version of the image.
It depends on Server, Server should support scaling down the image.
In addition to the other answers there is one solution that may work without special software on server side;
If the images are stored on the server in JPEG format and uses the interlaced / progressive mode you would be able to download them partially for creating a thumb nail.
This special mode was designed to see a preview-image while it is still downloading. Compacting the preview image could result in an image that can be used as a thumbnail.
However I don't know a library that would support thumbnail loading this way.