WidthMinusOne = 385 -> 110000001
HeightMinusOne = 394 -> 110001010
I've tried to understand some of the code found below the point https://chromium.googlesource.com/webm/libwebp/ but I did not succeed. Anybody out there who can help me please?
Hello, I have started to develop some pure Python code for lossless images based on this document: https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#6_overall_structure_of_the_formatAfter reading the first 21 bytes, I ran into trouble. The next 14 + 14 bits are supposed to indicate width and height of the image resp. but the retrieved bits do not reflect the expected values. From sample image 2_webp_ll.webp e.g. I retrieved the bit sequences 10000001100000 and 01011000100001, but I can't see how these correspond to the values indicated by my viewer (IrfanView):WidthMinusOne = 385 -> 110000001
HeightMinusOne = 394 -> 110001010
I've tried to understand some of the code found below the point https://chromium.googlesource.com/webm/libwebp/ but I did not succeed. Anybody out there who can help me please?
On Tuesday, 29 December 2020 at 18:32:41 UTC+1 Steven H. wrote:Hello! After searching the web, I tend to believe that Python developers are all depending on the PIL package or the related Pillow package to read (and write) this new format. If however somebody could point out to me how to do it with another package, I'd be very happy. Especially if that other package is written in pure Python! If no such package exists, how difficult would it be to develop it?What I have understood so far, is that webp files are read block by block. I find this particularly interesting because this would allow the reading of a large webp image without the need to first load the whole file into memory.FYI: I'm developing a package that so far reads / writes image files line by line and therefore makes sure that the required memory remains low. This is useful when the image is very large - e.g. acquired by a sensor on board of a satellite. If a webp image can at least be processed block by block, then it's the next format I'd like to add to the supported formats. Thanks!
--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msgid/webp-discuss/1514a893-0d03-449d-ae58-34956787b3e8n%40webmproject.org.
Hello Pascal,Thanks for the reply! Yes, I intend to write new code. In the document https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification, the following 2 lines are given:int image_width = ReadBits(14) + 1;
int image_height = ReadBits(14) + 1;Basically, I'm looking for a Python equivalent to the function ReadBits. I believe I'm retrieving the 14 bits from the file correctly. Somehow I must be making a mistake in the conversion of the 14-bit sequence to integer. I'm familiar with converting integers stored in bit sequences with length 8 or multiples of 8 and byteorder little endian, but this is different. Can you explain how the 14 bits are decoded in the function ReadBits? Thank you in advance!
On Monday, 4 January 2021 at 22:04:13 UTC+1 pascal.m...@gmail.com wrote:Hi Steven,On Mon, Jan 4, 2021 at 5:59 PM Steven H. <dobe...@gmx.net> wrote:Hello, I have started to develop some pure Python code for lossless images based on this document: https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#6_overall_structure_of_the_formatAfter reading the first 21 bytes, I ran into trouble. The next 14 + 14 bits are supposed to indicate width and height of the image resp. but the retrieved bits do not reflect the expected values. From sample image 2_webp_ll.webp e.g. I retrieved the bit sequences 10000001100000 and 01011000100001, but I can't see how these correspond to the values indicated by my viewer (IrfanView):WidthMinusOne = 385 -> 110000001
HeightMinusOne = 394 -> 110001010
I've tried to understand some of the code found below the point https://chromium.googlesource.com/webm/libwebp/ but I did not succeed. Anybody out there who can help me please?
You probably want to get familiar with the container first: https://developers.google.com/speed/webp/docs/riff_containerNow, regarding the image's dimension, the bitstream contains the actual dimension minus one because no image can have width/height values of 0.So one might as well forbid this possibility. If you look at 2_webp_ll.webp, it's indeed a 386 x 395 image.Regarding the python wrapper, there's a SWIG one in the library but it's only partial (decoder only).Still, you may consider it a starting point, in case you don't want to rewrite the whole wrapper.hope it helps,skal/On Tuesday, 29 December 2020 at 18:32:41 UTC+1 Steven H. wrote:Hello! After searching the web, I tend to believe that Python developers are all depending on the PIL package or the related Pillow package to read (and write) this new format. If however somebody could point out to me how to do it with another package, I'd be very happy. Especially if that other package is written in pure Python! If no such package exists, how difficult would it be to develop it?
--What I have understood so far, is that webp files are read block by block. I find this particularly interesting because this would allow the reading of a large webp image without the need to first load the whole file into memory.FYI: I'm developing a package that so far reads / writes image files line by line and therefore makes sure that the required memory remains low. This is useful when the image is very large - e.g. acquired by a sensor on board of a satellite. If a webp image can at least be processed block by block, then it's the next format I'd like to add to the supported formats. Thanks!--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msgid/webp-discuss/1514a893-0d03-449d-ae58-34956787b3e8n%40webmproject.org.
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msgid/webp-discuss/2855c7fa-f88d-4c14-890b-3388d98811ddn%40webmproject.org.