Confusion about encoding WebP with sampling Factor

128 views
Skip to first unread message

Khawar Islam

unread,
Oct 13, 2020, 1:47:14 PM10/13/20
to WebP Discussion
I have converted Kodak 24 images eith sampling factor 420.
convert test/images/kodim$i.png -quality $(($j*5)) -sampling-factor 4:2:0 test/jpeg/kodim$i/`printf "%02d" $j`.jpg

I need same procedure for WebP
convert test/images/kodim$i.png -quality $(($j*5)) -define webp:lossless=true test/webP/kodim$i/`printf "%02d" $j`.webp

Both convert lines are correct or not. I want to compare the results

Jyrki Alakuijala

unread,
Oct 14, 2020, 3:41:12 AM10/14/20
to webp-d...@webmproject.org
WebP lossless stores data in RGB, which is similar (slightly better) than YUV444 and a lot better than YUV420.

--
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/54ae7b6a-0f72-4b03-8d8d-2e102e6c13c4n%40webmproject.org.

Pascal Massimino

unread,
Oct 14, 2020, 4:00:50 AM10/14/20
to WebP Discussion
On Tue, Oct 13, 2020 at 7:47 PM Khawar Islam <khaw...@gmail.com> wrote:
I have converted Kodak 24 images eith sampling factor 420.
convert test/images/kodim$i.png -quality $(($j*5)) -sampling-factor 4:2:0 test/jpeg/kodim$i/`printf "%02d" $j`.jpg

I need same procedure for WebP
convert test/images/kodim$i.png -quality $(($j*5)) -define webp:lossless=true test/webP/kodim$i/`printf "%02d" $j`.webp

If you want to compare *lossless* WebP, it should be against their PNG equivalent. They use the same colorspace (ARGB),
and same compression technique (lossless coding based on lz77 algorithm).

If you want to compare *lossy* WebP to JPEG, then you have no choice but using YUV420, which is the only available
colorspace available.

I'd advise using 'cwebp' instead of 'convert', to get better control over fine encoding options.

hope it helps,
skal/



Both convert lines are correct or not. I want to compare the results

--

Khawar Islam

unread,
Oct 14, 2020, 4:48:44 AM10/14/20
to WebP Discussion, pascal.m...@gmail.com
JPEG is lossy image compression and i want same thing for WebP. I am using imageMagick tool for conversion

Like for JPEG, below code generated  20 images with different quality factor of each kodak image for comparison

for i in {01..24..1}; do
echo JPEG Encoding test/images/kodim$i.png
mkdir -p test/jpeg/kodim$i
for j in {1..20..1}; do
convert test/images/kodim$i.png -quality $(($j*5)) -sampling-factor 4:2:0 test/jpeg/kodim$i/`printf "%02d" $j`.jpg
done
done

For WebP conversion

for i in {01..24..1}; do
echo WebP Encoding test/images/kodim$i.png
mkdir -p test/webP/kodim$i
for j in {0..20..1}; do
convert test/images/kodim$i.png -quality $(($j*5)) test/webP/kodim$i/`printf "%02d" $j`.webp
done
done


Am i correct?. the above code did not generates webP images with different quality factors. All images are same. Please help me

James Zern

unread,
Oct 14, 2020, 5:15:10 PM10/14/20
to WebP Discussion, pascal.m...@gmail.com
Hi,

On Wed, Oct 14, 2020 at 1:48 AM Khawar Islam <khaw...@gmail.com> wrote:
JPEG is lossy image compression and i want same thing for WebP. I am using imageMagick tool for conversion

Like for JPEG, below code generated  20 images with different quality factor of each kodak image for comparison

for i in {01..24..1}; do
echo JPEG Encoding test/images/kodim$i.png
mkdir -p test/jpeg/kodim$i
for j in {1..20..1}; do
convert test/images/kodim$i.png -quality $(($j*5)) -sampling-factor 4:2:0 test/jpeg/kodim$i/`printf "%02d" $j`.jpg
done
done

For WebP conversion

for i in {01..24..1}; do
echo WebP Encoding test/images/kodim$i.png
mkdir -p test/webP/kodim$i
for j in {0..20..1}; do
convert test/images/kodim$i.png -quality $(($j*5)) test/webP/kodim$i/`printf "%02d" $j`.webp
done
done


Am i correct?. the above code did not generates webP images with different quality factors. All images are same. Please help me

This looks to be working correctly for me using:
$ convert -version
Version: ImageMagick 6.9.11-24 Q16 x86_64 20200718 https://imagemagick.org

As Pascal mentioned, you can also try cwebp to compare.
 



On Wednesday, 14 October 2020 at 17:00:50 UTC+9 pascal.m...@gmail.com wrote:
On Tue, Oct 13, 2020 at 7:47 PM Khawar Islam <khaw...@gmail.com> wrote:
I have converted Kodak 24 images eith sampling factor 420.
convert test/images/kodim$i.png -quality $(($j*5)) -sampling-factor 4:2:0 test/jpeg/kodim$i/`printf "%02d" $j`.jpg

I need same procedure for WebP
convert test/images/kodim$i.png -quality $(($j*5)) -define webp:lossless=true test/webP/kodim$i/`printf "%02d" $j`.webp

If you want to compare *lossless* WebP, it should be against their PNG equivalent. They use the same colorspace (ARGB),
and same compression technique (lossless coding based on lz77 algorithm).

If you want to compare *lossy* WebP to JPEG, then you have no choice but using YUV420, which is the only available
colorspace available.

I'd advise using 'cwebp' instead of 'convert', to get better control over fine encoding options.

hope it helps,
skal/



Both convert lines are correct or not. I want to compare the results

--
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/54ae7b6a-0f72-4b03-8d8d-2e102e6c13c4n%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.

Khawar Islam

unread,
Oct 14, 2020, 10:47:56 PM10/14/20
to WebP Discussion, James Zern, pascal.m...@gmail.com
Thank you Sir Pascal. Below command works fine
cwebp test/images/kodim$i.png -q $(($j*5)) -o test/webP/kodim$i/`printf "%02d" $j`.webp

What is the default chroma sampling factor of above command?

Jyrki Alakuijala

unread,
Oct 15, 2020, 6:15:22 AM10/15/20
to webp-d...@webmproject.org, James Zern, pascal.m...@gmail.com
Your command creates a WebP lossy image at different qualities.

WebP lossy is always with YUV420 sampling, equivalent to imagemagick's -sampling-factor 2x2 (also -sampling-factor 4:2:0) for jpeg.


Khawar Islam

unread,
Oct 15, 2020, 8:08:47 AM10/15/20
to WebP Discussion, jyrki, James Zern, pascal.m...@gmail.com
Thank you. Its mean that i am right. 
Reply all
Reply to author
Forward
0 new messages