Quantcast

Fwd: TIFF image displayed upside down

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fwd: TIFF image displayed upside down

Vincent Torri
Hello

I am trying to display this multipage TIFF :
http://www.filedropper.com/multipagetiffexample
The result I get is in this png file : http://www.filedropper.com/tiff
I also want to say that it is the first time that I try to manage TIFF
files and that I use the libtiff library.

The code I use to display the tiff file is: http://pastebin.com/tUstLZz2

so the result is like I display the lines in the reverse order (from
bottom to top, and not from top to bottom)

note that orientation of the TIFF image is : row 0 top, col 0 lhs
(ORIENTATION_TOPLEFT).

Does someone see what the problem is ?

thank you

Vincent Torri
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Jürgen Buchmüller
Am Freitag, den 20.01.2017, 20:06 +0100 schrieb Vincent Torri:
> so the result is like I display the lines in the reverse order (from
> bottom to top, and not from top to bottom)

Is the framework you're using based on Windows bitmaps? For Windows
bitmaps with positive height (structure member
BITMAPINFOHEADER::bihHeight > 0) the scanline order is bottom to top.

Perhaps it's sufficient, if you set the height of the image in the
framework to the negative value of the real height (length in terms of
TIFF).

HTH
Jürgen

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Bob Friesenhahn
In reply to this post by Vincent Torri
On Fri, 20 Jan 2017, Vincent Torri wrote:

> Hello
>
> I am trying to display this multipage TIFF :
> http://www.filedropper.com/multipagetiffexample
> The result I get is in this png file : http://www.filedropper.com/tiff
> I also want to say that it is the first time that I try to manage TIFF
> files and that I use the libtiff library.
>
> The code I use to display the tiff file is: http://pastebin.com/tUstLZz2
>
> so the result is like I display the lines in the reverse order (from
> bottom to top, and not from top to bottom)
>
> note that orientation of the TIFF image is : row 0 top, col 0 lhs
> (ORIENTATION_TOPLEFT).
>
> Does someone see what the problem is ?

TIFF provides the TIFFTAG_ORIENTATION tag to obtain the image
orientation.  You need to obtain this tag's value and then decide what
needs to be done to display the image properly.

The image could also be rotated on its side.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Vincent Torri
In reply to this post by Jürgen Buchmüller
On Fri, Jan 20, 2017 at 8:19 PM, Jürgen Buchmüller <[hidden email]> wrote:
> Am Freitag, den 20.01.2017, 20:06 +0100 schrieb Vincent Torri:
>> so the result is like I display the lines in the reverse order (from
>> bottom to top, and not from top to bottom)
>
> Is the framework you're using based on Windows bitmaps? For Windows
> bitmaps with positive height (structure member
> BITMAPINFOHEADER::bihHeight > 0) the scanline order is bottom to top.

i know this (I did the windows port of that framework). It is a cross
platform one and the other images (png, jpeg, etc...) are correctly
displayed

Vincent Torri

> Perhaps it's sufficient, if you set the height of the image in the
> framework to the negative value of the real height (length in terms of
> TIFF).
>
> HTH
> Jürgen
>
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Vincent Torri
In reply to this post by Bob Friesenhahn
On Fri, Jan 20, 2017 at 8:24 PM, Bob Friesenhahn
<[hidden email]> wrote:

> On Fri, 20 Jan 2017, Vincent Torri wrote:
>
>> Hello
>>
>> I am trying to display this multipage TIFF :
>> http://www.filedropper.com/multipagetiffexample
>> The result I get is in this png file : http://www.filedropper.com/tiff
>> I also want to say that it is the first time that I try to manage TIFF
>> files and that I use the libtiff library.
>>
>> The code I use to display the tiff file is: http://pastebin.com/tUstLZz2
>>
>> so the result is like I display the lines in the reverse order (from
>> bottom to top, and not from top to bottom)
>>
>> note that orientation of the TIFF image is : row 0 top, col 0 lhs
>> (ORIENTATION_TOPLEFT).
>>
>> Does someone see what the problem is ?
>
>
> TIFF provides the TIFFTAG_ORIENTATION tag to obtain the image orientation.

as I have mentioned, the orientation is ORIENTATION_TOPLEFT, so it
should be good, no ?

> You need to obtain this tag's value and then decide what needs to be done to
> display the image properly.

what should i do then, as the orientation is ORIENTATION_TOPLEFT ?

> The image could also be rotated on its side.

with libtiff or the framework ?

Vincent Torri
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Olivier Paquet-2
In reply to this post by Vincent Torri
2017-01-20 14:06 GMT-05:00 Vincent Torri <[hidden email]>:
so the result is like I display the lines in the reverse order (from
bottom to top, and not from top to bottom)

man TIFFRGBAImageGet says:

"(Note  that  the  raster  is assume to be organized such that the pixel at location (x,y) is raster[y*width+x]; with the raster origin in the lower-left hand corner.)"

So TIFFRGBAImageGet will always reorient the image and it does it the "windows bitmap" way. 

Olivier

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Bob Friesenhahn
In reply to this post by Vincent Torri
On Fri, 20 Jan 2017, Vincent Torri wrote:
>>
>> TIFF provides the TIFFTAG_ORIENTATION tag to obtain the image orientation.
>
> as I have mentioned, the orientation is ORIENTATION_TOPLEFT, so it
> should be good, no ?

Sorry, I missed that.  It is quite possible that the file has the tag
wrong.  It is very easy for an application to get the tag wrong,
particularly if it did not create the original image.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Vincent Torri
In reply to this post by Vincent Torri
On Fri, Jan 20, 2017 at 8:51 PM, Olivier Paquet
<[hidden email]> wrote:

> 2017-01-20 14:06 GMT-05:00 Vincent Torri <[hidden email]>:
>>
>> so the result is like I display the lines in the reverse order (from
>> bottom to top, and not from top to bottom)
>
>
> man TIFFRGBAImageGet says:
>
> "(Note  that  the  raster  is assume to be organized such that the pixel at
> location (x,y) is raster[y*width+x]; with the raster origin in the
> lower-left hand corner.)"
>
> So TIFFRGBAImageGet will always reorient the image and it does it the
> "windows bitmap" way.

thank you, i know why :)

now, how can I use libtiff to display it correctly ? i've tried
several things, without success

Vincent Torri
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Bob Friesenhahn
On Fri, 20 Jan 2017, Vincent Torri wrote:
>>
>> So TIFFRGBAImageGet will always reorient the image and it does it the
>> "windows bitmap" way.
>
> thank you, i know why :)
>
> now, how can I use libtiff to display it correctly ? i've tried
> several things, without success

If the image is oriented in strips then you could use scanline-level
access with TIFFReadScanline().  This would mean that you need to
decode (unpack) the scanlines yourself.  This is much more efficient
than TIFFRGBAImageGet() but it is also quite a lot more work.

If you were able to run a utility on your target, then you could use
'tiffcrop' to rotate the image.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Olivier Paquet-2
In reply to this post by Vincent Torri
2017-01-20 14:57 GMT-05:00 Vincent Torri <[hidden email]>:
>> So TIFFRGBAImageGet will always reorient the image and it does it the
>> "windows bitmap" way.
>
> thank you, i know why :)
>
> now, how can I use libtiff to display it correctly ? i've tried
> several things, without success

I meant that this is normal if you use the TIFFRGBA API. You must
either reverse the data yourself or get your display toolkit to do it.

You could use a lower level libtiff API but then you'll have to handle
the orientation tags yourself so you won't be much better off if you
hit a TIFF which is not "top left".

Olivier
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

mickey.rose
In reply to this post by Vincent Torri

Od: Vincent Torri <[hidden email]>


On Fri, Jan 20, 2017 at 8:51 PM, Olivier Paquet
<[hidden email]> wrote:

> 2017-01-20 14:06 GMT-05:00 Vincent Torri <[hidden email]>:
>>
>> so the result is like I display the lines in the reverse order (from
>> bottom to top, and not from top to bottom)
>
>
> man TIFFRGBAImageGet says:
>
> "(Note that the raster is assume to be organized such that the pixel at
> location (x,y) is raster[y*width+x]; with the raster origin in the
> lower-left hand corner.)"
>
> So TIFFRGBAImageGet will always reorient the image and it does it the
> "windows bitmap" way.

thank you, i know why :)

now, how can I use libtiff to display it correctly ? i've tried
several things, without success

Vincent Torri



After you intiialize the TIFFRGBAImage structure with TIFFRGBAImageBegin,
set img->req_orientation = ORIENTATION_TOPLEFT (it defaults to BOTLEFT).
TIFFRGBAImageGet will then output the top row first.



_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Fwd: TIFF image displayed upside down

Vincent Torri
Hello

On Fri, Jan 20, 2017 at 11:33 PM, Mickey Rose <[hidden email]> wrote:

>
> Od: Vincent Torri <[hidden email]>
>
>
> On Fri, Jan 20, 2017 at 8:51 PM, Olivier Paquet
> <[hidden email]> wrote:
>> 2017-01-20 14:06 GMT-05:00 Vincent Torri <[hidden email]>:
>>>
>>> so the result is like I display the lines in the reverse order (from
>>> bottom to top, and not from top to bottom)
>>
>>
>> man TIFFRGBAImageGet says:
>>
>> "(Note that the raster is assume to be organized such that the pixel at
>> location (x,y) is raster[y*width+x]; with the raster origin in the
>> lower-left hand corner.)"
>>
>> So TIFFRGBAImageGet will always reorient the image and it does it the
>> "windows bitmap" way.
>
> thank you, i know why :)
>
> now, how can I use libtiff to display it correctly ? i've tried
> several things, without success
>
> Vincent Torri
>
>
>
> After you intiialize the TIFFRGBAImage structure with TIFFRGBAImageBegin,
> set img->req_orientation = ORIENTATION_TOPLEFT (it defaults to BOTLEFT).
> TIFFRGBAImageGet will then output the top row first.

it works perfectly. thank you

Vincent Torri
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Loading...