Gif to jpg help needed

Hi,
I have to convert a gif image to a jpg image but when I convert, the image size increases from 22 kbytes to 50 kbytes. is there a way I could convert the image without increasing the size in java?
can somebody help me with this. I would be very glad if somebody could help me with this.
I am using Jmagick for this.
MagickImage.setFormat("jpg");
I don't need it to be done using Jmagick, but if there is a way I would definitely like to know.
Thanks,
Samanth.

The size of the JPG depends on the content of the image itself; in most cases, the JPG is smaller than the GIF, even with high quality images. The size of the JPG can be controlled by how much information you are willing to lose; this is controlled by a parameter called Quality.
ImageMagick (and therefore JMagick, since this is only the Java interface to ImageMagick) has a parameter for setting the quality; in command-line tools, it is the parameter -quality; in programming, I think it is MagickSetCompressionQuality(); check the documentation. Quality ranges from 0 (lowest, barely recognizable) to 100 (highest)
Without JMagick, you can use the built-in ImageIO
//Read the file to a BufferedImage
BufferedImage image = ImageIO.read(new File("c:/temp/image.gif"));
Once you have the BufferedImage, you can write the image as a JPG. You will need to create a File object for the destination image. When calling the write() method, specify the type string as "jpg" (other formats are supported).
ImageIO.write(image, "jpg", new File("c:/temp/image.jpg"));

Similar Messages

  • Help Needed! To upload image to db2 using struts & hibernation[code inside]

    Hi all, currently i have successfully created the application for inserting text data into my db2 through the use of struts with hibernation. But i need to insert image now which seems to be different from just inserting text data.
    From my understanding, the image will be converted to bytes and store as Blob in my db2, but i need hlp in knowing how to do this, i did a search and i found the following codes posted by another guy in this forum but he did not reply his thread at all...i am feeling very puzzel about the last file which is /RegPersonalDetails.java. Did he missed out a bean file?? which is the TempPhoto bean? i really do not understand the last file, The first file is the JSP , the second is the bean and the third is the Action class. i did exactly the same as his but i do not know how to use the RegPersonalDetails.java. please help thanks.. i am using websphere studio 5 and hibernate 2.
    Below is the example i got from the guy:
    //Registration.jsp
    --Below is the script for image type validation.
    <script>
    var fileTypes=["bmp","gif","png","jpg","jpeg","tif","tiff","jif","jfif","jp2","jpx" ,"j2k","j2c","fpx","pcd" ];
    function preview(what){
    var source=what.value;
    var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
    for (var i=0; i<fileTypes.length; i++) if (fileTypes==ext) break;
    var globalPic=new Image();
    if (!(i><fileTypes.length)){
    alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", "));
    what.fileUpload.focus();
    return false;
    else
    return true;
    </script>--You have to write relevent code for view.For browse filed i given below
    <INPUT type=file name="fileUpload" onchange="preview(this)">
    ===============================================================
    //RegistrationForm.java
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    public class Regstep5Form extends ActionForm {
    private FormFile fileUpload;
    public FormFile getFileUpload() {
    return fileUpload;
    public void setFileUpload(FormFile fileUpload) {
    this.fileUpload = fileUpload;
    ===================================================================
    //RegistrationAction.java
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.upload.FormFile;
    public class Regstep5Action extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception, ServletException {
    Regstep5Form rf= (Regstep5Form)form;
    FormFile myFile = rf.getFileUpload();
    String contentType = myFile.getContentType();
    String fileName = myFile.getFileName();
    int fileSize = myFile.getFileSize();
    byte[] fileData = myFile.getFileData();
    String result=RegPersonalDetails.process(rf);
    System.out.println("result taken");
    return mapping.findForward("success");
    ===================================================================
    //RegPersonalDetails.java
    import com.model.orm.TempPhoto;
    import com.util.HibernateUtil;
    import org.hibernate.*;
    import java.io.*;
    import org.apache.struts.upload.*;
    public class RegPersonalDetails {
    public static String process(Regstep5Form rf) throws Exception {
    TempPhoto temp=new TempPhoto();
    Session session=null;
    Transaction tx=null;
    try{
    session = HibernateUtil.getSession();
    tx = session.beginTransaction();
    String uname=rf.getUserId();
    FormFile myFile=rf.getFileUpload();
    byte[] filedata=myFile.getFileData();
    temp.setUserId(uname);
    temp.setPhoto(filedata);
    session.saveOrUpdate(temp);
    tx.commit();
    }catch(Exception ex){ }
    finally{
    HibernateUtil.closeSession();
    return "success";
    --Here TempPhoto is the pojo class i.e hibernate generated class for the table in which we have to insert image...
    --You will understand this if u have idea of hibernate..
    --There may some import as statements missing...try it and configure your "struts-config.xml" file with the above files.
    Message was edited by:
    HaRou

    haha....that thread starter is my friend siting next to me....he is having problem with struts and jsp only, which you already solve the problem for him.. but i need to know how to do the same thing with hibernate...pls hlp?

  • Some GIFs and JPGs appearing with yellow "wash" when loading in Safari

    Hi,
    I've flicked through forums, google, and called my top graphics people but nobody can seem to help, or has ever even heard of, my issue.
    Here it is in a nutshell:
    Some GIFs and JPGs appear with a yellow "wash" when being loaded in Safari. I can confirm this is happening on 3 different Macs, and even on a PC running Safari.
    Safari 3.1.1 on Windows XP
    Safari 3.1.2 on Mac OSX 10.5.5
    Here's some examples of it occurring:
    http://staging.tomatosource.com.au/test/bad.jpg
    http://staging.tomatosource.com.au/test/bad.gif
    You might need to refresh the page in Safari a couple of times to see the flicker but it's there.
    I've tried:
    - resaving images with and without "progressive" and "interlaced"
    - a variety of different colour palettes
    - taking a screenshot of the image, putting back into Photoshop and resaving
    Has anybody seen this issue before? Unfortunately I can't go live with this site until I fix this very strange error.
    Any comments would be greatly appreciated!
    Cheers,
    Jase.

    Totally independently from your current problem, Safari is cr@p. Dump it.
    All Apple applications, from the Finder through Preview and iPhoto to Safari, assign Monitor RGB to ALL untagged images, even if they were created or saved in sRGB.
    The only current properly color-managed web browser is Firefox 3.0.1. Just keep in mind that you have to enable color management deep inside the guts of Firefox.
    See this existing thread in the Adobe Photography forum:
    Ramón G Castañeda, "Beware of using Adobe Web Galleries" #49, 14 Sep 2008 4:52 pm

  • Help needed on online theme creation for mobile phones

    Hello everybody,
    I want to create an web application which will create themes for different mobile phones. In that application end user can upload jpg/gif images of there choice and select the mobile phone make like Nokia and also the model number like 6030. After that they can create their desired theme by clicking on a button and also can download it.
    My main problem is how to convert an image into a mobile phone theme (*.thm or *.nth or *.sis).
    Can anybody give any suggestion on this matter?
    Thanks in advance.
    Tanmoy

    Hi everybody,
    My main problem is how to convert an image into a mobile phone theme (*.thm or *.nth or *.sis).
    Please give me any guideline that I can proceed.
    Help needed.
    Thanks in advance.
    Tanmoy

  • Creating a .gif or .jpg File

    I have written an eBook and am sending it for eBook publication and sale.
    One of the items required in the process before uploading the eBook is to provide:
    A. An image of the book cover. That image is now in Pages format and it contains text and a line art image. I need to convert that cover page to a .gif or .jpg format. How can I do this?
    B. The process also requires me to create 'Banners' of varying size. How do I create a Banner? All the material [text and art] are contained in the existing Pages document.
    Thank you,
    Leo
    <Edited by Moderator>

    Leo Gendernalik1 wrote:
    I have written an eBook and am sending it for eBook publication and sale.
    One of the items required in the process before uploading the eBook is to provide:
    A. An image of the book cover. That image is now in Pages format and it contains text and a line art image. I need to convert that cover page to a .gif or .jpg format. How can I do this?
    As far as I know, the only way to get a gif or jpg would be to make a screenshot.
    Maybe a PDF may fit your needs. If it does use the Print to PDF tool and print the 1st page.
    B. The process also requires me to create 'Banners' of varying size. How do I create a Banner? All the material [text and art] are contained in the existing Pages document.
    You may open a blank Numbers document and remove every table.
    You will get a huge blank surface which may be more than one meter in width.
    Copy objects from Pages and paste then on the Numbers sheet.
    Yvan KOENIG (from FRANCE samedi 14 juin 2008 21:25:00)

  • Help needed placing extra images in my portfolio.

    I like to add some more pictures by my portfoliomap.
    I have now 6 items each page and i like to know if its possible to add some more pictures and how i can do this?
    You can find my site at..
    http://www.dorffdesign.nl/affiches.html

    As you can see on
    http://www.dorffdesign.nl/advertenties.html
    it worked out fine..
    Only the last set off images contait to much space between the set before? Do you know where i can adjust this?
    Regards Brian
    Date: Tue, 17 Apr 2012 09:07:38 -0600
    From: [email protected]
    To: [email protected]
    Subject: Help needed placing extra images in my portfolio.
        Re: Help needed placing extra images in my portfolio.
        created by Altruistic Gramps in Dreamweaver - View the full discussion
    Upload the images to the images folder and use the markup as you have been using in the following, changing the name of the image to suit.
    !images/arcadisch_logo.jpg|alt=|src=images/arcadisch_logo.jpg!
    Gramps
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4340979#4340979
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4340979#4340979. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Dreamweaver by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How can I invalidate everything except .gif and .jpg

    Hi
    I need to invalidate every page except the static objects as gif jpg. Can I create a rule that invalidates everything except gif and jpg.
    Thanks

    currently webcache invalidation does not have the expressive power to describe "anything but".
    however, you can give a list of rules in single invalidation message, each matching one type of pages, such as under particular directory, and with fixed suffix. and the whole list of criteria effectively achieves "anything but".

  • Stylesheet help needed

    Created a stylesheet for multiple page website.  Works as expected on my computer.  Uploaded all files but the background image doesn't show up in any files.  Can someone explain what I did wrong?  I know there's more to do on the site but I'm just beginning to replace code with css.
    Thanks for any help.

    Because you haven't uploaded the file at this link yet:
    /Images/gradient.jpg
    You need to check that the file is on your server or that you have the correct name for background page.
    hth

  • Help needed with a design!

    HELP! I need help with designing something!
    IMAGE on this link " http://i1072.photobucket.com/albums/w362/jjnilsson/DSC_0188.jpg "
    i need this patch on the picture to be "remade" in higher definition and the text should be MILF HUNTERS intstead of milf hunter... Anyone that might be able to help me out?
    reson for all this is that its gonna be made to a 30x40cm big patch fitting the back of our Team jackets!
    send me a pm or a mail ([email protected]) if you need any futher info or if you can help me out! I am really thankful for all the help i can get!
    With best regards J. Nilsson, Milf Hunters Mc

    I simply did as i got a tip on FB to do
    quote from adobe themselves on facebook "Adobe Illustrator You might also want to try asking on our forums as there are many people that can help there as well! http://forums.adobe.com/community/illustrator/illustrator_general"
    sry if it was wrong of me, simply thought there might be someone nice out there to give a helping hand
    Date: Tue, 5 Jun 2012 13:41:48 -0600
    From: [email protected]
    To: [email protected]
    Subject: Help needed with a design!
        Re: Help needed with a design!
        created by in Illustrator - View the full discussion
    This really isn't the place to ask for free services.
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4467790#4467790
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4467790#4467790. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Illustrator by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Serious help needed fixing an image gallery

    On my page
    http://www.dorff.nl/clients.html
    ive put this very nice gallery..
    The only problem is. I divided the gallery in 6 groups. But in every group you will see the same images. How can i change the images for each group seperately?
    I hope you understand what i ment.
    Regards Brian

    How i can use the four files you have send me?
    In dreamweaver im getting the message...
    lightbox.css is not on the disk
    prototype.css is not on the disk
    scriptaculous.css is not on the disk
    lightbox.js is not on the disk
    Date: Thu, 12 Apr 2012 12:37:39 -0600
    From: [email protected]
    To: [email protected]
    Subject: serious help needed fixing an image gallery
        Re: serious help needed fixing an image gallery
        created by adninjastrator in Dreamweaver - View the full discussion
    Here are 4 files you need:http://www.olympicdiscoverytrail.com/style_sheets/lightbox.csshttp://www.olympicdiscoveryt rail.com/style_sheets/prototype.jshttp://www.olympicdiscoverytrail.com/style_sheets/script aculous.js?loa d=effectshttp://www.olympicdiscoverytrail.com/style_sheets/lightbox.jsHere is an entire web page with working multiple galleries:
    Photo Gallery 1
        !images/125/paw_Carrie-Elwha.jpg|title=Elwha River Valley approaching the bridge|height=93|alt=Elwha River Valley approaching the bridge|width=125|src=images/125/paw_Carrie-Elwha.jpg|border=0!
    Photo Gallery 2
        !images/125/sw_IMG_1115-Downtown-Trail.jpg|title=Trail near High School close to downtown Sequim|height=83|alt=Trail near High School close to downtown Sequim|width=125|src=images/125/sw_IMG_1115-Downtown-Trail.jpg|border=0!
       </div>     <!-- close main_container -->
    </div>
    </body>
    </html>Here is a link to that working page on-line:http://www.olympicdiscoverytrail.com/trail_maps/slideshow.htmlThere is not much more I can do!You'll have to take the bull by the horns and start coding!Copy/Paste this HTML code into a new, blank page and edit the paths to all the .css, .js, and image files.Best of luck!Adninjastrator
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4330648#4330648
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4330648#4330648. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Dreamweaver by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Troubleshoting help needed:  My iMac keeps crashing and restarting with a report detail: "spinlock application timed out"  What can I do to fix this?timed out"

    Troubleshooting help needed:  My iMac keeps crashing and restarting with a notice: "Spinlock application timed out"  What can I do?

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the page that opens.
    Select the most recent panic log under System Diagnostic Reports. Post the contents — the text, please, not a screenshot. In the interest of privacy, I suggest you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header and body of the report, if it’s present (it may not be.) Please don't post shutdownStall, spin, or hang reports.

  • Help needed for writing query

    help needed for writing query
    i have the following tables(with data) as mentioned below
    FK*-foregin key (SUBJECTS)
    FK**-foregin key (COMBINATION)
    1)SUBJECTS(table name)     
    SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
    2           02           Computer Science
    3           03           Physics
    4           04           Chemistry
    5           05           Mathematics
    7           07           Commerce
    8           08           Computer Applications
    9           09           Biology
    2)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
    383           S1      9           4           2           3
    384           S2      4           2           5           3
    ---------I actually designed the ABOVE table also like this
    3) a)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
    383           S1
    384           S2
    b)COMBINATION_DET
    COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
    1               383          9
    2               383          4
    3               383          2
    4               383          3
    5               384          4
    6               384          2          
    7               384          5
    8               384          3
    Business rule: a combination consists of a maximum of 4 subjects (must contain)
    and the user is less relevant to a COMB_NAME(name of combinations) but user need
    the subjects contained in combinations
    i need the following output
    COMB_ID COMB_NAME SUBJECT1 SUBJECT2      SUBJECT3      SUBJECT4
    383     S1     Biology Chemistry      Computer Science Physics
    384     S2     Chemistry Computer Science Mathematics Physics
    or even this is enough(what i actually needed)
    COMB_ID     subjects
    383           Biology,Chemistry,Computer Science,Physics
    384           Chemistry,Computer Science,Mathematics,Physics
    you can use any of the COMBINATION table(either (2) or (3))
    and i want to know
    1)which design is good in this case
    (i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
    good method to link with same table but if 4 subjects only(and must) comes
    detail table is not neccessary )
    now i am achieving the result by program-coding in C# after getting the rows from oracle
    i am using oracle 9i (also ODP.NET)
    i want to know how can i get the result in the stored procedure itsef.
    2)how it could be designed in any other way.
    any help/suggestion is welcome
    thanks for your time --Pradeesh

    Well I forgot the table-alias, here now with:
    SELECT C.COMB_ID
    , C.COMB_NAME
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
    FROM COMBINATION C;
    As you need exactly 4 subjects, the columns-solution is just fine I would say.

  • Help needed I have a canon 40D. I am thinking of buying a canon 6D.But not sure that my len

    Hi all help needed I have a canon 40D. I am thinking of buying a canon 6D.
    But not sure that my lenses will work.
    I have a 170mm/ 500mm APO Sigma.
    A 10/20 ex  Sigma   HSM  IF.
    And a 180 APO Sigma Macro or do I have to scrap them and buy others.
    ALL Help will be greatly received. Yours  BRODIE

    In short, I love it. I was going to buy the 5DMark III. After playing with it for a while at my local Fry's store where they put 5DMII, 5DMIII and 6D next to each other, using the same 24-105L lens, I decided to get the 6D and pocket the different for lens later.
    I'm upgrading from the 30D. So I think you'll love it. It's a great camera. I have used 5DMII extensively before (borrowing from a close friend).
    Funny thing is at first I don't really care about the GPS and Wifi much. I thought they're just marketing-gimmick. But once you have it, it is actually really fun and helpful. For example, I can place the 6D on a long "monopod", then use the app on the phone to control the camera to get some unique perspective on some scenes. It's fun and great. GPS is also nice for travel guy like me.
    Weekend Travelers Blog | Eastern Sierra Fall Color Guide

  • Help needed! Raid degraded again!

    Hi!
    Help needed! I hava made bootable RAID with two S-ATAII 250Gb HDD and its not working! Every now and then at bootup I get a message RAID -> DEGRADED... Must be seventh time! Rebuild takes its own time!
    What am I doing wrong!
    T: Ekku
    K8N Neo4 Ultra
    AMD 64 4200+
    2 Gb RAM
    2 x 250 Gb HDD (Maxtor)
    nVidia RAID (in mb)
    P.S. I wery SORRY with my poor language!

    I'm going to blame the nVRAID because I've seen issues with it in the past. If your motherboard has another non-nVidia RAID solution, use that instead. Using the nVidia SATA ports as BASE or JBOD is fine and dandy but RAIDing always had issues. It's not even a driver issue I think it's just instability. Latest drivers and even boxed drivers never helped. Granted, some will report success with their rig. But on a professional level I've seen nForce issues on different motherboards and different hard drives that had RAID disaster stories.
    Good luck and if you don't have another RAID solution, my suggestion would be to buy a dedicated RAID controller card.
    LPB

  • HELP NEEDED WITH ADDAPTER-DVI TO VGA.

    PLEASE ...HELP NEEDED WITH WIRING CROSS OVER....CAN YOU HELP WITH BACK OF PLUG CONNECTIONS...I SORTA UNDERSTAND THE PINOUTS BUT CANT MAKE AN EXACT MACH...WOULD LIKE TO BE 100% SURE...
    ......THIS ENSURES NO SMOKE!!!                                                                                           
    THE CARD IS AN ATI RADEON RX9250-DUAL HEAD-.........ADDAPTER IS DVI(ANALOG)MALE TO VGA(ANALOG)FEMALE.
    ANY HELP VERY MUCH APPRECIATED........ SEEMS YOU NEED TO BE ROCKET SCI TO ATTACH A BLOODY PICTURE...SO THIS HAS BEEN BIG WASTE OF FING TIME!

    Quote from: BOBHIGH on 17-December-05, 09:21:31
    Get over it mate !
    I find it easy t read CAPS...and if you dont like it ...DONT READ IT!
    And why bother to reply...some people have nothing better to do.
    Yes there chep and easy to come by...Ive already got a new one.
    All I wanted was to make a diagram of whats inside the bloody thing...it was a simple question and required a simple answer.
    NO NEED TO A WANKA !!
    I feel a bann comming up.
    Have you tryed Google ? really.. your question is inrelevant. No need to reply indeed.
    Why do you come here asking this question anyway ? is it becouse you have a MSI gfx card ? and the adapter has nothing to do with this ?
    You think you can come in here yelling.. thinking we have to put up with it and accept your style of posting. This is not a MSI tech center.. it's a user to user center.. Your question has nothing to do with MSI relavant things anyway's.
    Google = your friend.
    Quote from: BOBHIGH on 17-December-05, 09:21:31
    it was a simple question and required a simple answer
    Simple for who ? you (buying a new one) ? me ? we ?   .really...........
    Quote from: Dynamike on 16-December-05, 04:11:48
    1: There are allot of diffrent types of those adapters.
    If any of the mods have a problem about my reply.. please pm me.

Maybe you are looking for