Someone once gave me a jpg with a size of 1024*1024 and a size of 99 kb. The size of each layer is as follows: Unit: kb
The jpg pyramid I generated is processed by any
Height256 46.2kb
Height512 162kb
Height1024 557kb
The jpg pyramid generated by Photoshop is processed by any processing
Height256 48kb
Height512 90kb
Height1024 163kb
It can be seen that the size of this image is too big to be understood. I finally read the previous blog post and read the metadata to see why:
Retrieve metadata Functions
Copy codeThe Code is as follows: public void GetProperty ()
{
Bitmap myImage1024 = new Bitmap (@ "E: \ myjpg \ height.jpg ");
Foreach (PropertyItem property in myImage1024.PropertyItems)
{
StringBuilder sb = new StringBuilder ();
Byte [] sbbyte = (Byte []) property. Value;
Sb. AppendFormat ("ID: {0}, Length: {1}, Type: {2}; \ n ",
Property. Id. ToString (), property. Len. ToString (), property. Type. ToString (),);
Console. Write (sb );
}
}
I found that the generated jpg file is different from the metadata of the original image.
Height1024:
ID: 771, Length: 1, Type: 1; header information Tag explanation: 303 PropertyTagSRGBRenderingIntent
ID: 769, Length: 8, Type: 5; header information Tag explanation: 301 PropertyTagGamma
ID: 20752, Length: 1, Type: 1; header information Tag explanation: 5110 PropertyTagPixelUnit resolution
ID: 20753, Length: 4, Type: 4; header information Tag explanation: 5111 PropertyTagPixelPerUnitX
ID: 20754, Length: 4, Type: 4; header information Tag explanation: 5112 PropertyTagPixelPerUnitY
Height:
ID: 20625, Length: 128, Type: 3; header information Tag explanation: 5091 PropertyTagChrominanceTable
ID: 20624, Length: 128, Type: 3; header information Tag explanation: 5090 PropertyTagLuminanceTable
In this way, we can see why jpg is different in size. Well, I modified the method for generating the image pyramid: Remove their header information before saving the pyramid. Then I was surprised to find that the finest layer of the image pyramid I generated is the same size as the original image !.
Methods for removing image metadata:
Copy codeThe Code is as follows: public void RemoveProperty ()
{
Bitmap myImage1024 = new Bitmap (@ "E: \ myjpg \ height.jpg ");
Foreach (PropertyItem property in myImage1024.PropertyItems)
{
MyImage1024.RemovePropertyItem (property. Id );
}
MyImage1024.Save (@ "E: \ myjpg \ nopro.jpg ");
}