-4

I'd like to use the compiled libjpeg-9 example.c and transupp.c code and libraries to rotate a .jpg image in an Eclipse project.

Working progress on achieving this from the start: Compiling/using libjpeg in Windows for Eclipse

Trying to integrate do_rot_180 and read/write functions into one location: Need help compiling jpegtran.c code from libjpeg

Community
  • 1
  • 1
Enigma
  • 1,247
  • 3
  • 20
  • 51
  • Do you want to **flip** the image or **rotate** the image 180°? I.e. do you want to upper-left to translate to lower-left or lower-right? – Robᵩ Jan 29 '13 at 15:48
  • 3
    You seem to have tagged this with 'libjpeg', so you're aware of it... Then? –  Jan 29 '13 at 15:49
  • 1
    FWIW, from the Linux command line: `$ convert input.jpg -rotate 180 output.jpg`. – Robᵩ Jan 29 '13 at 15:51
  • 1
    Have a look at http://stackoverflow.com/questions/12802231/lossless-jpeg-rotation-during-decoding-with-libjpeg It's not a duplicate of your question but might get you started. – Tony Jan 29 '13 at 15:54
  • So what is the problem? Is your code not working or are you looking for somebody to provide you with code? If it's the latter, SO might not be a good choice for that. – dandan78 Jan 29 '13 at 15:55

2 Answers2

5

do_rot_180 function in transupp.c in libjpeg (you are aware of it as the Q has the tag) is doing exactly what you want.

LOCAL(void)
do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
        jvirt_barray_ptr *src_coef_arrays,
        jvirt_barray_ptr *dst_coef_arrays)
/* 180 degree rotation is equivalent to
 *   1. Vertical mirroring;
 *   2. Horizontal mirroring.
 * These two steps are merged into a single processing routine.
 */

The function is used by jtransform_execute_transformation/JXFORM_ROT_180 and loslessy reorders JPEG's internals to achieve rotation effect. This function demonstrates the use and rotates a given file and writes a new modified file using specified transformation (angle).

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • The keyword is `jtransform_execute_transformation`, you will find a lot of code snippets online e.g. http://read.pudn.com/downloads151/sourcecode/graph/652797/jpegtran.c__.htm - this does it simple: from file to file and rotation type as parameter. – Roman R. Jan 29 '13 at 17:46
  • 1
    Ready to use function is insufficient? Better than that is only when someone writes code for you. – Roman R. Jan 29 '13 at 18:48
  • No, it is not archaic, it's you having issues building simple C++ application based on `libjpeg`. I am not sure what is the best solution here, either `1` sort issues out and build the app, or `2` find command line tool that does it for you, or `3` build `libjpeg` samples and see how exactly they are designed and structured. You don't have to use `libjpeg`, use GDI+ or anything else that does rotation in a more convenient (for you) way. – Roman R. Jan 29 '13 at 18:56
  • To add to this, it is not a *simple task*. It is a beauty of JPEG that lossless rotation in efficient way is even possible in first place. – Roman R. Jan 29 '13 at 18:59
  • Your mistake is that you think it's an easy separate task. No, JPEG image is not a matrix of pixels. It's an image encoded into a bitstream, and rotation is a complex task. You will have to find a way to compile it because otherwise you just won't be able to leverage the function that does the task of your interest. – Roman R. Jan 29 '13 at 19:13
  • Yes, you can decode and then re-encode. It is subject to quality loss, less efficient also, hardly simpler in terms of source code. – Roman R. Jan 29 '13 at 19:21
1

Have you get a look at the imagemagick library? it's free and very powerful tool

Tony
  • 9,672
  • 3
  • 47
  • 75
VB9-UANIC
  • 330
  • 1
  • 5