Converting a Image File

gujuraja143 used Ask the Experts™
I am farely new with Java.  The question that I had was that I have a jpeg file that I would like to convert it to another format.  

I want to store some metadata in this new file that I am creating with the image there, so basically I want to creat a new file type or a new image file type (hopefully something called .xpg or something similiar).  

.jpg --->  add more metadata --(save as)--> .xpg

Is this possible?

thank you experts.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Java Developer
Top Expert 2010
Of course it is :)
You can save your image data in whatever format you like.
There are lots of examples of image encoders on the following page which should be a good starting point 4u:

The simplest way is to use JAI (Java Advanced Imaging) from Sun. Normally with JAI you load a image and save'it transparently in which supported format you want. Before downloading JAI, take a look at default encoders provided there and see if there is a match to the one you want.


Well the other question I had was that I wanted to save the file as a .xpg or another file type, I wanted to make up my own format.  I understand how to convert the .jpg and load it into java, but how would i save it as a different file time.

This file type, I made it up for the application that I am making.   I want it to convert the .jpg and save it as that file type.  This file type is exactly like the .jpg file but it just has more metadata that is stored in that I need for the application.

Mick BarryJava Developer
Top Expert 2010

I realise what you are trying to do.
I supplied you with a reference to existing source code for image encoders to use as a starting poit and a guide for your development.
Should be a simple matter to take one of these and change the format the data is saved to disk.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial