Lossless JPEG rotation

Is there anything in 1.4.1's imageio package that will help me rotate a JEPG w/o changing the quality or messing up the Exif headers? Or, does anybody know of a good 3rd party lib?
I've heard this can be done (assuming your image is a supported size or aspect) by 'juggling some bytes' at the beginning of the JPEG file, w/o actually converting the whole file. Is this a stable approach?
The other option I see is trying to stick the Exif headers back on to the file after rotating it with Java 2D- but then I'm re-encoding the JPEG and messing with the quality and I wanted to avoid doing that.
Thanks for your help. Amazingly, there is very little documented on this topic in the Java world.

I am also in need of a EXIF writer so that I can edit JPEGs without forfiting the meta-data. If anyone has created an API, please contact me: gabrielm[at]pdx[dot]edu.
cheers,
gabrielmcgovern

Similar Messages

  • Unable to process Lossless JPEG Images..

    Hi,
    I have jdk 1.6.0. and i installed the jai-Imageio pakage.i am not able view the true lossless jpeg
    image.
    I tried to open a lossless jpeg image from the code given in
    http://forums.sun.com/thread.jspa?forumID=20&threadID=335960
    but the
    image does not open. It works for jpeg, jpeg2000 images. but not
    lossless jpeg and jpeg-ls images..
    when i try to code
    String s[] = ImageIO.getReaderFormatNames();
    for(int i=0;i< s.length ;i++)
    System.out.println(s);
    it prints
    raw
    BMP
    JPEG2000
    RAW
    jpeg
    tif
    jpeg2000
    WBMP
    GIF
    TIF
    TIFF
    jpg
    bmp
    PNM
    JPG
    pnm
    wbmp
    png
    JPEG
    PNG
    jpeg 2000
    JPEG 2000
    gif
    tiff
    if i try to load lossless jpeg image it shows the exception that
    but when i write code like
    CLibJPEGImageReaderSpi cl = new CLibJPEGImageReaderSpi();
    String s[] = cl.getFormatNames();
    for(int i=0;i< s.length ;i++)
    System.out.println(s[i]);
    it prints
    jpeg
    JPEG
    jpg
    JPG
    jfif
    JFIF
    jpeg-lossless
    JPEG-LOSSLESS
    jpeg-ls
    JPEG-LS
    if i check with 'cl.canDecodeInput(imageInputStream)' it returns true.
    i d't now how to load the image using 'CLibJPEGImageReaderSpi' class object
    or is there any other way to load the image ?
    can anybody write the full code to display the true lossless jpeg image
    which is taken from dicom medical images. the images are available at
    http://rapidshare.com/files/250911269/Lossless_jpeg.zip.html
    is there any website has good tutorial about lossless jpeg image. what
    is point transform in lossless jpeg ? what old pseudo lossless jpeg ?
    what is equivalent for that in java ?

    You can email me one of the Pics (zip it first) but it sounds like they are toast.

  • Unable to Open Lossless JPEG Image

    Hi,
    I have jdk 1.6.0. and i installed the jai-Imageio pakage.i am not able view the true lossless jpeg
    image.
    I tried to open a lossless jpeg image from the code given in
    http://forums.sun.com/thread.jspa?forumID=20&threadID=335960
    but the
    image does not open. It works for jpeg, jpeg2000 images. but not
    lossless jpeg and jpeg-ls images..
    when i try to code
    String s[] = ImageIO.getReaderFormatNames();
    for(int i=0;i< s.length ;i++)
    System.out.println(s);
    it prints
    raw
    BMP
    JPEG2000
    RAW
    jpeg
    tif
    jpeg2000
    WBMP
    GIF
    TIF
    TIFF
    jpg
    bmp
    PNM
    JPG
    pnm
    wbmp
    png
    JPEG
    PNG
    jpeg 2000
    JPEG 2000
    gif
    tiff
    if i try to load lossless jpeg image it shows the exception that
    but when i write code like
    CLibJPEGImageReaderSpi cl = new CLibJPEGImageReaderSpi();
    String s[] = cl.getFormatNames();
    for(int i=0;i< s.length ;i++)
    System.out.println(s[i]);
    it prints
    jpeg
    JPEG
    jpg
    JPG
    jfif
    JFIF
    jpeg-lossless
    JPEG-LOSSLESS
    jpeg-ls
    JPEG-LS
    if i check with 'cl.canDecodeInput(imageInputStream)' it returns true.
    i d't now how to load the image using 'CLibJPEGImageReaderSpi' class object
    or is there any other way to load the image ?
    can anybody write the full code to display the true lossless jpeg image
    which is taken from dicom medical images. the images are available at
    http://rapidshare.com/files/250911269/Lossless_jpeg.zip.html
    is there any website has good tutorial about lossless jpeg image. what
    is point transform in lossless jpeg ? what old pseudo lossless jpeg ?
    what is equivalent for that in java ?

    There are two images in that zip file. I have no problems reading the one called "lossless.jpg". It's a 16-bit grayscale image that's completely black. The one called "test.jpg" throws an exception. Is this what you're getting? I'm using JAI-ImageIO 1.1
    is there any website has good tutorial about lossless jpeg image. what
    is point transform in lossless jpeg ? what old pseudo lossless jpeg ?
    what is equivalent for that in java ? In addition to describing normal jpeg encoding, the jpeg specification also describes what's called "lossless jpeg" encoding. Lossless jpegs - as described in the original specification - are obsolete. No common application can open them. It doesn't help that the png format (also lossless) provides much smaller file sizes then lossless jpeg's.
    Both of the jpegs in that zip file are lossless jpegs. Incidently, I can't open them up with Irfanview or Adobe Photoshop CS4 (wich says alot). And I can only read "lossless.jpg" with JAI-ImageIO while the other one throws an IOException. By using lossless jpegs, the user cripples portability.
    JPEG-LS is different from lossless jpeg. In fact, it was meant to replace lossless jpegs. While not actually lossless, jpeg-ls is described as a "near lossless" compression. I believe the files have a +.jls+ extension instead of a +.jpg+ one. While not obsolete (I think), JPEG-LS is not widely used. Using it can still cripple portability.
    The JPEG2000 format also has a "lossless" mode, that again, is not widely used. Using it can still cripple portability. JPEG2000 files have a +.jp2+ extension.
    Lastly, I don't know what you mean by this question
    what is point transform in lossless jpeg?PS: I have no problems reading a lossless jpeg or a jpeg-ls that I write with JAI-ImageIO. So maybe there's something wrong with "test.jpg" in the zip file?

  • Achieving lossless JPEG quality?

    What is the best way to achieve lossless JPEG quality in Photoshop? Is setting the quality of the file to "maximum" essentially lossless? I've been using .png files a lot more, but some of my clients still don't welcome that format. Thanks!

    Lossless JPEG is a bit of a misnomer. It is part of the original JPEG standard (Annex H to CCITT Recommendation T.81), but it does not use the compression technique (DCT compression) that is the primary feature of JPEG, often referred to as JPEG compression. Instead it uses either Hoffmann or arithmetic coding. It also can be used for 16-bit image data, unlike the lossy JPEG format. I'm not sure what the point was to it, given that there are other lossless compressed and non-compressed formats, such as TIFF. It has rarely been implemented, probably for that very reason. According to the
    Wikipedia entry for Lossless JPEG, it has been used in some medical imaging applications and is used in, of all things, DNG and some cameras' RAW formats (perhaps the encoding technique is used, rather than the image format). There two other techniques mentioned there: JPEG-2000, mentioned above, and JPEG-LS, which is nearly lossless.

  • Lossless JPEG

    Hello,
    I am a beginner to image compression. I am doing a project on Image Compression.
    As part of it, I am implementing predictive-based lossless JPEG
    algorithm. I am facing a problem in that. Can anybody please provide solution to my problem?
    Problem: If we choose 2-dimensional predictors such as A + (B – C)/2, B +
    (A – C)/2, (A + B)/2 for prediction, then prediction error will be
    fractional. How to handle these fractions before Huffman encoding? (Note:
    I am using huffman encoder)
    eg: Predictor function= A + (B – C)/2, and A= 230, B= 235, C= 232 then
    prediction error= 231.5
    If i simply approximate the value to nearest integer, then image that we
    get after decoding would be lossy. So, can you please tell me how to
    handle these fractions.
    Thanks in advance,
    Regards,
    Suresh Yerva,
    IIIT DM Jabalpur,

    809792 wrote:
    As part of it, I am implementing predictive-based lossless JPEG
    algorithm. I am facing a problem in that. Can anybody please provide solution to my problem?This forum is for discussion of the Java Media Framework API and for help with instances of that. It isn't a general purpose AV forum.
    Your best bet would be to post this question in the "Java Programming" forum, or possibly the "Java Advanced Imaging" forum (even though that, too, is a specific API forum)

  • How to perform lossless JPG rotation?

    If I rotate a JPG 90/180/270 degrees in Preview or iPhoto or Aperture, will it be a lossless rotation? If not, are there plugins or third party apps that can?

    g-pod:
    iPhoto does lossless rotate. You can check it out by rotating a photo and then dragging it to the desktop. Check the size in the Finder and drag it into an open Safari window do confirm that it has been rotated. Safari does not read the orientation tag so it's a good test.
    Happy New Year
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Lossless JPG rotation with Preview?

    If I rotate a JPG in Preview, will it be a lossless rotation?

    I had my question answered here: http://discussions.apple.com/message.jspa?messageID=6233761
    Thanks for directing me to that part of the forum.

  • Preview jpeg rotation strangeness

    Hi,
    when I open a jpeg picture that I've downloaded (or dragged to the Desktop from Safari or Firefox) with Preview, rotate the picture in Preview and then save and reopen it (again with Preview), the picture is not rotated.
    Preview seems to work on the picture, because the the modification date is changed after saving it, but it is not rotated.
    I've read about the EXIF-compatible way Preview rotates pictures, but this should only cause problems with other applications, not Preview itself.
    Furthermore not all jpegs are affected, but most I've tried, since I've discovered the problem.
    Jpegs I've created with PS work rotate just fine in Preview.
    Maybe someone can shed some light on this.
    Preview version is 3.0.9 (409).
    Regards
    Oliver
    MacBook Mac OS X (10.4.9) C2D, 2Ghz, 2GB RAM, 120GB HD

    I've seen the same thing and have been searching Discussions, only to find that this appears to be a bug introduced with 10.4.9

  • Lossless rotation

    Is there an official answer out there to the question - "Does iPhoto '07 perform lossless jpeg rotations ?"
    (sorry if this has been answered, but I can't find it)
    Thx.

    There's a contextual application, Photo Tool, that will rotate losslessly. Rotating a file with Photoshop acutally increases the file size. A 3 MB jpg file went to 4.3 MB jpg file. The same goes for Photoshop Elements.
    I've run across some sites discussing the additional compressions that jpgs go thru when being edited and what I came away with is that unless you're enlarging the files tremendously, you'll be hard pressed to see the difference. It will take many re-compressions before it becomes obvious to the naked eye.
    I read where iPhoto 7 now is now supposed to be somewhat lossless in its edits. I just ran a test on a file and here's what I got:
    original = 2.2 MB
    first edit (retouch tool to remove item from image) = 2.0 MB
    second edit (Adjust pane to change exposure, histogram and shadow lightness) = 2.2.
    third edit (rotate 90 degrees) = 2.2 MB
    export the edited file to the desktop = 2.2 MB
    It appears that iPhoto is performing as advertised in regards to lossless or near lossless editing.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Apple TV:  Problems displaying photos properly

    I have sync'd the Apple TV to my "My Pictures" folder. For some reason when viewing a slideshow of these photos some of them that are shown in "portrait" on my computer are displaying in "landscape" on the tv. I'm stumped on how this happened and what to do to correct it. It doesn't turn all photos to landscape so I don't know what is unique about the ones it has done that to. Any ideas for me? It's driving me nuts!
    Thanks!

    These are probably JPGs.
    Photos are either truly portrait i.e. they're saved from an editor with data organised in this orientation, or have their orientation set by various flags.
    Many cameras will set a 'flag' to indicate the camera was held portrait during shooting but not all do.
    Resaving JPGs as portrait will usually recompress them losing quality due to reordering rows and columns, but there is a flag in the JPEG header that can control orientation without affecting the data and is referred to as lossless rotation, and some software can change this setting.
    If an image is truly Portrait then it should show ok on AppleTV.
    The potential problem lies with the other 2 methods.
    Sometimes only the manufacturer's display/editing software knows that a shot was portrait (due to a manyfacturer's flag in the EXIF data) - consequently it shows it ok, but other apps or devices still think it's a landscape image.
    I can't remember if AppleTv handles lossless JPEG rotation or not.
    Windows XP's image preview rotation function isn't lossless (last time I used it anyway), so any photos rotated with that should show as portrait.
    Can you remember how you rotated images to portrait, or if the viewing software on XP just knew they were?
    A portrait image could also have a rotation flag set that makes it show landcsape even when it isn't.
    AC
    Message was edited by: Alley_Cat

  • Jpeg lossless rotation in organizer?

    Currently using PSE 4, but moving up to 7 soon.  I've read in previous threads that within the Organizer jpeg rotation is lossless, however I've observed that after doing an initial set of rotations there is a decrease in file size*; subsequent rotations however, do not change the file size. Does anyone have an explanation for this observation, and is the rotation not lossless afterall?  (*For purposes of viewing vertically oriented images correctly in Windows XP and Vista, I've found that I need to rotate the images horizontally and then back vertically, otherwise they remain oriented horizontally when viewed outside Elements.  This is problematic when burning images on CD/DVD to share with others.)  Thanks.
    Ethan

    Also, I looked in Edit>Preferences>Files, as well as elsewhere in PSE4, and found no information or option for rotation using orientation metadata.
    I no longer have PSE 4 installed. But the options may be called Edit > Preferences > Files >Fast JPEG Rotation and Fast TIFF Rotation -- ignore any description you may find in the PSE 4 User Guide, since based on what I see in the PSE 5 Guide, it's completely garbled.  (The names of the options and their descriptions got fixed by PSE 7.)
    In PSE7, if the option were unchecked, I'm assuming all vertically oriented images would come in horizontally, and thus require rotation anyway.  If this is so, I'm not sure what's gained by unchecking the option?
    When you take a vertically oriented photo with many newer cameras, the camera records the actual JPEG image horitontally oriented, and it records in the file's metadata the following setting:
    Orientation: Rotate 90 CW
    In general, when you import a photo into PSE 7, it always obeys the setting of the Orientation field, regardless of the setting of Rotate JPEGs Using Orientation Metadata. So when you import that vertically oriented image into PSE 7, it will come in correctly oriented, vertically.
    If you then export that photo and view it in a non-conforming application, the photo will appear horizontally oriented, because that's how the actual image is recorded in the file and because the application ignores the Orientation field.
    If you uncheck the option and then rotate counter-clockwise, PSE changes the orientation field to:
    Orientation: Horizontal (normal)
    and it leaves the actual JPEG image untouched, since it is already horitontally oriented.  If you then rotate clockwise, PSE leaves the orientation field as:
    Orientation: Horizontal (normal)
    and it rotates the actual JPEG image to vertical orientation.  When you export that version to non-conforming applications, they will see the image vertically oriented.
    When experimenting with this, be aware that at least some downloaders (e.g. the Windows Live Photo Gallery downloader) will read the Orientation field in a photo and rotate the actual JPEG image accordingly (depending on the options you've set).  They do this precisely because not all apps conform to the industry standard for the Orientation field.

  • Is the JPEG compression option on TIF files lossy or lossless?

    Is the JPEG compression option on TIF files lossy or lossless?

    I accidentally used the JPEG compression on some important TIFF images.  I usually use
    no compression but didn't realise the option had been chosen.  I can't easily re-scan.  I have
    read about lossless JPEG and with TIF considered a lossless format I had hoped this may
    be the case.

  • Is save for web in JPEG format lossless when quality is 100%?

    I am trying to figure out if I can reduce optimised JPEG sizes further than what Photoshop can offer.
    My boss has recently questioned whether the file sizes can be reduced using lossless JPEG's further than the sace for web function in photoshop.
    From what I can make of it, lossy is the option on GIF files, and therefore I am assuming that the optimisation is lossless for a JPEG at 100 percent quality and lossy when the quality is reduced?
    I just want to clarify that I am saving images for the web at the smallest size I can without losing too much quality.
    All the images I save are 450px wide @ 75 dpi, but vary in length from 800px high to 1500px high, but have to be saved under 100kb.
    Can anyone clarify the lossless and lossy in JPEG format in save for web?
    Thanks
    Ray

    As c. says above, JPEG is a lossy compression - there is no lossless JPEG.
    PNG 24bit offers lossless compression, that is it performs compression analogous to a zip archive, whereas JPEG works by (in extremely lay terms) building a new image that resembles the original.
    GIF and PNG exports let you reduce the number of colours to get better compression - there are fewer pixel differences to compress at 8bit colour depth. Hence a 16 colour PNG will have a vastly smaller file size than a 24bit PNG, and depending on the image may be much smaller than a similar quality JPEG.
    Depending on how far off your 100KB ceiling you are, you may be able to improve your file exports by cleaning up the source image - reduce noise and if possible explore exporting as 8bit pngs with fewer colours - avoid using diffusion or noise in the export options. Find the balance between acceptable file size and image quality... photographs tend to be the hardest thing to compress because there's so much detail data, especially in darker (low light) areas.

  • [Solved] Lossless JPG Cropping?

    I'm looking for a simple tool to crop and flip/rotate jpg or jpeg images losslessly.
    Most probably some sort of jpegtran frontend.
    It can be command line, but a simple gui would be nice.
    Another feature I want would be overwriting the original.
    jpegtran itself would require 3 commands for every image: it doesn't get the logic right when I crop AND flip, so I need to do that in 2 commands, and then i need to force move the new file back onto the original.
    I have investigated this, and came up with (and discarded):
    - cropgui and cropgtk (I cannot enter a fixed ratio. It's very hard to drag the selection pixel-precise, and it changes by a few pixels every time I move it. It doesn't have flip/rotate. It doesn't overwrite originals)
    - ljcrop (would seem to suit my needs but hopelessly outdated? I actually managed to find the file here but it's not running, missing the Tcl Img package)
    - viewnior is simple and has all the functions but i cannot get any information on how it performs cropping/flipping/rotating and whether it is lossless)
    I have tried a few more, mostly from this list.
    Last edited by ondoho (2014-04-26 19:19:50)

    emeres wrote:What about running Jpegcrop with wine or any other of the windows software listed? (that list is long) Works fine for me, however it is an another frontend for jpegtran.
    Appreciated, but i'm not installing wine for that.
    anyhow, i have done some reading on lossless jpeg crop/rotate, and there are some limitations that are set by jpeg's compression itself.
    this kind of brings down my whole idea, because i need to crop areas of the exact same dimension out of many different jpg images, and that exactly is not possible losslessly. at least not pixel-precise.
    otherwise, cropgui is a great tool.
    emeres wrote:By the way, how do you determine there is lossless cropping? Technically you would have to compare bytes of the original and cropped section.
    i trust the documentation.
    also, if the saved cropped files size is larger than the original, or i get an extra dialog asking what quality i want to use, my guess is it's not lossless.
    i'm marking this solved now. should have probably done that earlier.

  • Improve quality of JPEG images

    Hi
    I have an application which saves images in JPEG format after editing (well, many applications does that, but this is only a fraction of what this application does) :-)
    I can't use any other formats due to size restrictions. The problem is Image Editing module of this application has operations like line drawing and text inserting. When I save the image, fine lines (especially texts) are getting blurred.
    Is there any way I can increase the quality of JPEG files saved? I understand that JPEG is not meant for sharp lines and texts but with Photoshop, even fine lines and texts appear good when saved as a high quality JPEG file. Is there any such method in Java by which I can increase the quality of JPEG images?
    Thanks in advance...

    Is there any way I can increase the quality of JPEG files saved? I understand that JPEG is not meant for sharp lines and texts but with Photoshop, even fine lines and texts appear good when saved as a high quality JPEG file. Is there any such method in Java by which I can increase the quality of JPEG images?I JPEG is a non-conservative compression format (you do not get back exactly what you put in, it has "acceptable degredaton"--I talked with the author before it became popular and he explained what JPEG was all about--high compresses resulting in a small size for internet communications over dialup.
    In more recent times I've seen quality factors brought into play with JPEG, but as you have stated, even in Adobe Photoshop under the highest quality, you still have degradation. I've seen some hint and some state that you can get a lossless JPEG, but I've not encountered it yet.
    In any case, if you do find a "lossless JPEG" the size of that file is going to be bigger than you are looking at now. You may consider other file formats--TIFF or there are even more recent files formats that have higher conservative compression algorithms.

Maybe you are looking for

  • Target Documents G/L Account on the Details Line is not Updated

    Hello, I am trying to promote a Sales Order into a Delivery Note. The Sales Order lines are created using a particular warehouse.  The customer may pick up the items from a different location, so we would promote the Sales Order and modify the wareho

  • Using bind variables in on-demand process

    Are bind variables referring to session state items supported in queries in an on-demand application process? All the examples I see show how to pass client side values using the $v() function and the addParam method of the htmldb_get object and refe

  • Looking for a custom vBios for a 980M

    I am looking for a custom vBios for a 980m with +135/+330. I tried to reply to the other thread but it wouldn't let me for some reason? My bios says GT70 2QE (upgraded a 2PE from 880m). Trying to circumvent the ol' nVidia lockdown. Thanks for your he

  • User adding extra form boxes

    Hello, I'm not sure what the exact parlance is here but can anyone advise me on how about doing the following? Like on many Airline websites the user can click a button to 'add another passager' or whatever and a new form box/form boxes pop-up undern

  • My iPod 4th gen has a lock with a circle/arrow what is it and how do I get rid of it?

    There is a lock with a circle/arrow around it it is near the battery what is it and how do I get rid of it?