I am working on a app where I would like to download images from a website and then save those images into a sqlite database. I tried already to find some good tutorials and the only thing that came close to what I would like to do, is a article by Tim Bray.
http://android-developers.blogspot.de/2010/07/multithreading-for-performance.html
The code is really nice however it does not account for saving each single image. Bitmap unfortunatley (as far as I understand) does not distinguish between each image.
I would like to ask if anybody could give me some pointers or even better has source code for such a problem.
If you want to store images into a database you can store them as a BLOB-value.
Take a look here for that part: http://www.tutorialforandroid.com/2009/10/how-to-insert-image-data-to-sqlite.html
Related
I don't know if this is a super noob question, but I'm currently building an app from scratch with the knowledge i've gained so far, and I'm making a "Notes" app where You can create notes, delete, edit(update), etc etc.
The question I'm having is that I know I can use a database to store data from my input, and I know i can use A Database to save, open the data, but Just incase, does Java have a LocalStorage, like JavaScript/JSON where you can save things and open them up later?
If there is LocalStorage for applications to save data, and open it up after running again, what would be some good resources to read about it and learn it so I may integrate it into my application?
If there is no localstorage, I wan't to be able to perhaps allow the user to add images when creating notes, how would I be able to do that using a database?
As far that I know of there packages that allow you to store data as you intend, but following on your next question, you could possibly store the address/file name of the image you wants to add to the database. You could then use it to retrieve the image file and display it.
If you have any questions on image implementing images in java, reference this documentation and tutorial
If you have any more questions on working with databases, reference this documentation
I hope this helps.
I'm developing an Android application but I need some help.
I need to store about 2000 image in high resolution (1024x768 and about 2.5 MB each) and the application must work offline so i can't retrieve them from an online database or from anywhere else. These picture should be stored in the SQLite db inside the application because each one of them are related to a specific product.
I've tried to convert the picture to a Base64 string but the result is too big and the app crash. It works only if it's about 467x300 and 30 KB but it loose all its quality so this is not a good solution.
Hope you have helpful suggestions. Thank you.
The way this problem is typically solved is to not store the images in the database, but rather store a link to them in the database. If you want them to be private, store them in the private app storage location. Getting images from a database is tricky, and editing binary blobs like that can be tricky. It can cause issues in the database, which might cause things to be slower. Also, it's easier to load images from a file than from a database.
Also, you could use BLOB, which allows for storing binary data. SQLite supports that, so...
Here is what I did to handle my high resolution images:
give a unique image id to the image, stored in the database
save the image in the android storage
whenever I need a high res image, get its name from the database. use the name to look up the image from storage.
I'm happy to provide a code example, just let me know.
I am currently developing a website in which several images will be displayed on a single page. In light of performance, I'm searching for the best way to handle thes images.
First, I will explain my needs. The back-end of the website consists of a CMS in which images can be uploaded (and maybe resized by the user so the image will have the neede ratio of width/height). These images will be displayed on several pages in de website, requested by (hopefully) many users.
Secondly, I will shortly describe my environment. I am developing in Java EE, using JSF as front-end. I am using multiple libraries like Prime Faces et cetera.
I have done some research and it seems there are dozens of solutions, but I don't know in which direction to search. E.g.:
Saving images in database
Saving images as static images by using for example filestreams
So in short:
Which way of saving and requesting images would be best in this case?
What library would you advice to serve me in this?
Is there a JSF-solution to manually resize images?
Would ImageJ be the best solution to generate thumbnails? If not, what would be?
If any other details are needed, I'm happy to provide them.
Thanks in advance.
I wouldn't worry about performance until it becomes an issue. I would perhaps worry more about auditability, maintainability etc.
In order to make a future change easy, however, is abstract away your image store such that you can easily replace (say) a file-based system, with a database system (or a cloud-storage solution, or, or...).
That way you can easily substitute one for another and compare/constrast if need be, or simple swap out your implementation at a later date.
So..
Saving images as files is best
After some research it seems that PrimeFaces offers ImageCropper
File Upload can be achieved using PrimeFaces' FileUpload
But still, I have seen many discussions on Image Manipulation by Java and the best tooling for this. Some say ImageJ would be great, others don't. Is there any reason why I should go with one or another?
I have a series of images generated at the servlet. I want to show the images on a JSP page.
I want to show the images in a way that the JSP page is not refreshed only the image gets refreshed and get replaced by the new one. I thought of doing it with the help of applet or AJAX. But I am still looking for some convenient way of doing it. can anyone suggest some way of doing it? Any help is much appreciated.
Thanks in advance.
I'd go with JavaScript if I were you. It should be pretty simple to have a list of images and set a timer to change the source of the image tag every second (or whatever). You probably don't even need "real" AJAX for that... just changing the attributes in the DOM.
Admittedly it may not look great if the images take a while to load - you might want to have some cunning mechanism to load all the images beforehand, and then change which one is visible at any one time, or something like that. It still shouldn't need AJAX or an applet though.
I'm not sure I'd describe this as a "video-like" experience - more like a slide-show - but it should be okay. If you want real video, use video :)
There are a lot of simple jQuery image slideshow libraries that are easily added to your page and can add some great effects - for example:
http://nivo.dev7studios.com/#usage
I am writing a web application that has a page that returns a list of results of objects that each have a profile photo.
I am unsure of how large I expect this page to get, but I want to account for it getting to a larger level. Right now, I am only returning 5-10 objects each with an associated photo, and I am seeing a performance decrease.
I am aware there are many resources on the internet regarding image optimization, and I have done some research, but am still lost as to what I should do to optimize this page.
I know that using css-sprites is an option, but these photos are added by members, so I'm not sure If I could keep up with updating the CSS Sprite.
I am also aware that some image types might be better for performance, but sometimes with a loss of compatibility(although I have read articles that argue against this, and say it is something of the past).
I am fairly new to the concept of needing to optimize images on my page, so if there is a more advanced technique that somebody believes might be over a more novice developers ability, then it might be the wrong thing for me.
Any advice would help. If I try one and am unable to figure out the answer, I can always try another.
I realize this is something that can go on StackOverFlow's sister website regarding web design, but I would like to get the server side of it as well because there may be some fixes I need to make when I am uploading the file, so please no comments on how this is not fit for StackOverflow, Thanks!
a good way of optimisng images is using cache, and plus thumbnail them!
if you dont know about caching:
this is good tutorial to start for
webdesigners/ devlopers:Cache Tutorial for web authors`
this is good tutorial on creating images into thumbnails using php and Gd(which comes default with php)
just check incase
Create thumbnails using PHP and GD`
Thumbnail them server-side to the EXACT dimensions needed, then convert them to a jpeg. Also, if possible, just use one "default" photo for all of the users then load the individual profile photos via AJAX once the page has loaded.