Thumbnail not correctly stored by Microsoft JPEG Encoder
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Thumbnail-not-correctly-stored-by-Micros/1587311)._
---
Saving an Image by the Microsoft JPEG Encoder stores the Thumbnail incorrectly (APP1 Exif Entry).
Wrong produced by JPEG Encoder (JPEG Image File):
FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 60
00 60 00 00 FF E1 0C 40 45 78 69 66 00 00 4D 4D
00 2A 00 00 00 08 00 00 00 00 **00 0E** 00 06 01 03
00 03 00 00 00 01 00 06 00 00 01 1A 00 05 00 00
00 01 00 00 00 5C 01 1B 00 05 00 00 00 01 00 00
00 64 01 28 00 03 00 00 00 01 00 02 00 00 02 01
00 04 00 00 00 01 00 00 00 6C 02 02 00 04 00 00
00 01 00 00 0B CC 00 00 00 00 00 00 00 60 00 00
00 01 00 00 00 60 00 00 00 01 FF D8 FF DB 00 43
...
The TIFF tag countfield 000E should be at address X'26" instead of X'2A'
Preceding image was produced by following program:
Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
Dim file1 As String
Dim file2 As String
Dim dec1 As BitmapDecoder
Dim enc1 As JpegBitmapEncoder
Dim stream1 As System.IO.FileStream
Dim stream2 As System.IO.FileStream
Dim bmp1 As BitmapSource
Dim bmp2 As BitmapSource ' Thumbnail
Dim transform1 As ScaleTransform
Dim frame1 As BitmapFrame
file1 = "d:\testfiles\jpeg\MM Jpeg.jpg"
stream1 = New System.IO.FileStream(file1, IO. FileMode.Open, IO. FileAccess.Read)
dec1 = BitmapDecoder.Create(stream1, Nothing, Nothing)
bmp1 = dec1. Frames(0)
transform1 = New ScaleTransform
transform1. ScaleX = 0.125
transform1. ScaleY = 0.125
bmp2 = New TransformedBitmap(bmp1, transform1)
enc1 = New JpegBitmapEncoder
enc1. QualityLevel = 75
file2 = "d:\temp\MM JPEG created by JPEGencoder.jpg"
stream2 = New System.IO.FileStream(file2, IO. FileMode.Create, IO. FileAccess.Write)
frame1 = BitmapFrame.Create(bmp1, bmp2, Nothing, Nothing)
enc1. Frames.Add(frame1)
enc1. Save(stream2)
stream2. Close()
End Sub
Correct example:
FF D8 FF E0 00 10 4A 46 49 46 00 01 02 01 00 60
00 60 00 00 FF E1 0D CC 45 78 69 66 00 00 4D 4D
00 2A 00 00 00 08 00 07 01 12 00 03 00 00 00 01
00 01 00 00 01 1A 00 05 00 00 00 01 00 00 00 62
01 1B 00 05 00 00 00 01 00 00 00 6A 01 28 00 03
00 00 00 01 00 02 00 00 01 31 00 02 00 00 00 1B
00 00 00 72 01 32 00 02 00 00 00 14 00 00 00 8D
87 69 00 04 00 00 00 01 00 00 00 A4 00 00 00 D0
00 00 00 60 00 00 00 01 00 00 00 60 00 00 00 01
41 64 6F 62 65 20 50 68 6F 74 6F 73 68 6F 70 20
43 53 20 57 69 6E 64 6F 77 73 00 32 30 30 35 3A
31 31 3A 31 35 20 30 30 3A 31 32 3A 32 37 00 00
00 00 00 03 A0 01 00 03 00 00 00 01 FF FF 00 00
...
---
### Original Comments
#### Feedback Bot on 11/18/2021, 02:26 PM:
(private comment, text removed)
#### Feedback Bot on 3/2/2022, 01:19 PM:
(private comment, text removed)
#### Fiona Niu [MSFT] on 6/30/2022, 03:59 PM:
(private comment, text removed)
#### Urs Hürlimann on 7/12/2022, 00:42 PM:
(private comment, text removed)
#### Urs Hürlimann on 7/15/2022, 09:30 PM:
(private comment, text removed)
#### Urs Hürlimann on 7/15/2022, 09:34 PM:
(private comment, text removed)
#### Urs Hürlimann on 8/16/2022, 10:17 AM:
(private comment, text removed)
#### Urs Hürlimann on 7/4/2022, 07:16 PM:
(private comment, text removed)
#### Feedback Bot on 7/5/2022, 00:25 PM:
(private comment, text removed)
#### Pankaj Chaurasia [MSFT] on 7/11/2022, 11:16 PM:
(private comment, text removed)
#### Pankaj Chaurasia [MSFT] on 7/12/2022, 00:46 PM:
(private comment, text removed)
#### Urs Hürlimann on 7/13/2022, 05:05 PM:
(private comment, text removed)
#### Pankaj Chaurasia [MSFT] on 7/15/2022, 04:55 PM:
(private comment, text removed)
#### Urs Hürlimann on 7/15/2022, 09:39 PM:
(private comment, text removed)
#### Pankaj Chaurasia [MSFT] on 7/19/2022, 10:39 AM:
(private comment, text removed)
#### Urs Hürlimann on 7/19/2022, 00:26 PM:
(private comment, text removed)
#### Feedback Bot on 8/16/2022, 10:57 AM:
(private comment, text removed)
---
### Original Solutions
(no solutions)
Contributor guide
Assessment
This issue has not been assessed yet.