Rotate a Jpeg image 90 degrees

Posted on 1998-10-04
Last Modified: 2013-12-25
WHere can I find some C source that will allow me to read a jpeg image rotate it and write it out? OR a plug-in that will allow a jpeg image to be rotated on a web page?
THanks in advance..

Question by:rcashon
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1865745
search in yahoo with keyword IMAGE FORMAT.u will find
a plenty of routines in diffent platforms.
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1865746
Your best bet here is Java. Java 1.1 has built-in functions for cropping, streching and rotating gif and jpg and if the functions are made public, JavaScript can control it.


Expert Comment

ID: 1865747
well, depending on your specific preferences...couldn't you just have another image that was the same image just sideways?
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 75

Expert Comment

by:Michel Plungjan
ID: 1865748
I think rcashon wants to save space and download time...


Author Comment

ID: 1865749
Sorry to reject your answer sasidhar. I have been all over the web searching for some source.

 You hit the nail on the head for me. I need a java applet that can rotate a jpeg. Repost your comment for the points.  

Thanks to both of you for the reponces...


LVL 75

Accepted Solution

Michel Plungjan earned 20 total points
ID: 1865750
Your best bet here is Java. Java 1.1 has built-in functions for cropping, streching and rotating gif and jpg and if the functions are made public, JavaScript can control it.



I have seen the code in Java in a Nutshell. I can post some if you wish?

Author Comment

ID: 1865751
michel, Thanks I would greatly appreciate the code. I have been torn BTW writing some C code (which I still want to do  ) to read a jpeg file and rotate it or as you suggested to use a java applet and go that route. SirCaleb - you are correct in your statement. That is what I was what I was going to do with the C code. I was going to read in the image file rotate it and redisplay it. I just have not found any C code to facilitate that yet. Hopefully the applet code will do what I am wanting to do .
Thanks again...

LVL 75

Expert Comment

by:Michel Plungjan
ID: 1865752
Here you are:

// This example is from _Java Examples in a Nutshell_. (
// Copyright (c) 1997 by David Flanagan
// This example is provided WITHOUT ANY WARRANTY either expressed or implied.
// You may study, use, modify, and distribute it for non-commercial purposes.
// For any commercial use, see

import java.applet.*;
import java.awt.*;

/** An applet that demonstrates image scaling, cropping, and flipping */
public class ImageSampler extends Applet {
  Image i;

  /** Load the image */
  public void init() {  i = getImage(this.getDocumentBase(), "tiger.gif"); }

  /** Display the image in a variety of ways */
  public void paint(Graphics g) {
    g.drawString("Original image:", 20, 20);     // Display original image
    g.drawImage(i, 110, 10, this);               // Old version of drawImage()

    g.drawString("Scaled Images:", 20, 120);     // Display scaled images
    g.drawImage(i, 20, 130, 40, 150, 0, 0, 100, 100, this);  // New version
    g.drawImage(i, 60, 130, 100, 170, 0, 0, 100, 100, this);
    g.drawImage(i, 120, 130, 200, 210, 0, 0, 100, 100, this);
    g.drawImage(i, 220, 80, 370, 230, 0, 0, 100, 100, this);

    g.drawString("Cropped Images:", 20, 250);    // Display cropped images
    g.drawImage(i, 20, 260, 70, 310, 0, 0, 50, 50, this);
    g.drawImage(i, 80, 260, 130, 310, 25, 25, 75, 75, this);
    g.drawImage(i, 140, 260, 190, 310, 50, 50, 100, 100, this);

    g.drawString("Flipped Images:", 20, 330);    // Display flipped images
    g.drawImage(i, 20, 340, 120, 440, 100, 0, 0, 100, this);
    g.drawImage(i, 130, 340, 230, 440, 0, 100, 100, 0, this);
    g.drawImage(i, 240, 340, 340, 440, 100, 100, 0, 0, this);

    g.drawString("Scaled, Cropped, and Flipped:", 20, 460);  // Do all three
    g.drawImage(i, 20, 470, 170, 550, 90, 70, 10, 20, this);


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question