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
Related
I have been going through to achieve Multi-Resolution in android built in eclipse.
I have this app where i have used a lot of images, firstly the only limitation i have is size, i cannot exceed 5MB size for the app, surprisingly i was able to do this by just storing only in the xxhdpi folder, not all of the dpi folders, such as ldpi, mdpi and above xxhdpi devices dont support the app.
As you can see if i store all the folders with the respective images, it makes the app of size almost 15MB. I have read in forums that in cocos2dx there is a function to which only image is provided, which automatically scales the image with the device, and returns it to be set respectively,
i was wondering if there is a way to do this in android as well, thanx in advance
You'd better use SVG (vectorial images) files, through a 3rd party library.
SVGs are scalable (up or down, doesn't really matter) without loosing definition, due to their vectorial nature (it's just an xml file with geometrical definitions and color transitions).
This way, you'd have only 1 version of the graphical file and then only get the desired bitmap from it, with no ugly pixellation.
The most used libraries so far are android-svg and svg-android, primarily (there are a few other ones, and some variants to the proposed ones too).
Scaling is what they are meant to: you provide the SVG file (possibly in your raw or assets folder) and the needed dimensions (in pixels).
And get your bitmapped image out of the vectors.
Fantastic.
Our user Paul LeBeau is the author of AndroidSVG and he always lends a friendly support to whom needs a hand with his library.
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
Which is faster, to recieve images as JPG from server, and save it, then show it in a ListView or what ever
OR
receive images in an XML (as encoded String) from server, then decode it, then show it in a ListView (or even save it then show it from memory)
what is the best way (regarding performance) in transfering images FROM a server TO an android device
thanks in advance
That depends on where the limitation is. If the bandwidth of your connection is very small try to transfer as few bytes as possible. However, high compression usually costs more CPU, so if CPU power is limiting you it may be better to use a lower compression.
I am not sure what you mean by "receive images in an XML". Is it some vector format like SVG? That would normally be much smaller than a raster image (especially for large sizes).
To sum up, you will need to do some experiments to find out what works best in your case.
The best way is to get the image URL from the server and then download the image using some image managing library like https://github.com/nostra13/Android-Universal-Image-Loader or google's volley. These kind of libraries highly configurable and taking care of all the aspects of managing a bitmap.
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.
I developed a mass file up loader (a swing application) recently.One of the new requirements is to support uploading thousands of documents (GIF,JPG,PNG,DOCX,XLSX), each of these are like 3MB-10MB of size and we don't want to upload these huge files, we generally support TIFF files which has small byte size like 60KB-100KB. We are not concerned about the image quality, all we need to upload these docs for future reference. Right now I don't have any idea how to solve this problem, I started researching it. Please point me in right direction.
-PD
My first approach would be to convert them to pdf files. Everything that can be printed can be converted to pdf. This also allows for image compression. Tiff won't be a good idea for doc/xls I think, it might make them bigger.
a .doc or .xlsx can be gzipped very quickly for decent savings.
Images are more risky, depends on what the data is. Pictures of people? Pictures of text?