0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Progressive JPEG か Baseline JPEG かを判定する

Last updated at Posted at 2023-07-31

準備

exiftool を使います。

brew install exiftool

サンプル画像

こちらを使います。

Progressive JPEG の場合

Encoding ProcessProgressive であることが確認できます。

curl -s https://example.com/cdn-cgi/image/width=150,height=150,fit=cover,format=jpeg/https://sample-videos.com/img/Sample-jpg-image-30mb.jpg \
| exiftool -
result.txt
ExifTool Version Number         : 12.60
File Size                       : 0 bytes
File Modification Date/Time     : 2023:07:31 11:30:34+09:00
File Access Date/Time           : 2023:07:31 11:30:34+09:00
File Inode Change Date/Time     : 2023:07:31 11:30:34+09:00
File Permissions                : prw-rw----
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Image Width                     : 150
Image Height                    : 150
Encoding Process                : Progressive DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 150x150
Megapixels                      : 0.022
curl -s https://example.com/cdn-cgi/image/width=3000,height=3000,fit=cover,format=jpeg/https://sample-videos.com/img/Sample-jpg-image-30mb.jpg \
| exiftool -
result.txt
ExifTool Version Number         : 12.60
File Size                       : 0 bytes
File Modification Date/Time     : 2023:07:31 11:32:18+09:00
File Access Date/Time           : 2023:07:31 11:32:18+09:00
File Inode Change Date/Time     : 2023:07:31 11:32:18+09:00
File Permissions                : prw-rw----
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Image Width                     : 3000
Image Height                    : 3000
Encoding Process                : Progressive DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 3000x3000
Megapixels                      : 9.0

Baseline JPEG の場合

Encoding ProcessBaseline であることが確認できます。

curl -s https://example.com/cdn-cgi/image/width=150,height=149,fit=cover,format=jpeg/https://sample-videos.com/img/Sample-jpg-image-30mb.jpg \
| exiftool -
result.txt
ExifTool Version Number         : 12.60
File Size                       : 0 bytes
File Modification Date/Time     : 2023:07:31 11:34:03+09:00
File Access Date/Time           : 2023:07:31 11:34:03+09:00
File Inode Change Date/Time     : 2023:07:31 11:34:03+09:00
File Permissions                : prw-rw----
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Image Width                     : 150
Image Height                    : 149
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 150x149
Megapixels                      : 0.022
curl -s https://example.com/cdn-cgi/image/width=3000,height=3001,fit=cover,format=jpeg/https://sample-videos.com/img/Sample-jpg-image-30mb.jpg \
| exiftool -
result.txt
ExifTool Version Number         : 12.60
File Size                       : 0 bytes
File Modification Date/Time     : 2023:07:31 11:35:34+09:00
File Access Date/Time           : 2023:07:31 11:35:34+09:00
File Inode Change Date/Time     : 2023:07:31 11:35:34+09:00
File Permissions                : prw-rw----
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Image Width                     : 3000
Image Height                    : 3001
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 3000x3001
Megapixels                      : 9.0

参考

参考: Cloudflare Image Resizing の挙動

While you can use the format=jpeg option to generate images in an interlaced progressive JPEG format, we will fallback to the baseline JPEG format for small and large images specified when:

The area calculated by width x height is less than 150 x 150.
The area calculated by width x height is greater than 3000 x 3000.
For example, a 50 x 50 tiny image is always formatted by baseline-jpeg even if you specify progressive jpeg (format=jpeg).

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?