mirror of
https://github.com/Syping/ragephoto-cli.git
synced 2025-12-04 16:51:48 +01:00
GetJpeg() now fails with same exception message as GetSize()
This commit is contained in:
parent
63bee738b2
commit
5395f8ee2e
1 changed files with 21 additions and 16 deletions
19
Jpeg.cs
19
Jpeg.cs
|
|
@ -30,7 +30,15 @@ internal class Jpeg {
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Byte[] GetJpeg(Stream input, bool imageAsIs, out Size size) {
|
internal static Byte[] GetJpeg(Stream input, bool imageAsIs, out Size size) {
|
||||||
if (!imageAsIs) {
|
try {
|
||||||
|
if (imageAsIs) {
|
||||||
|
using MemoryStream jpegStream = new();
|
||||||
|
input.CopyTo(jpegStream);
|
||||||
|
Byte[] jpeg = jpegStream.ToArray();
|
||||||
|
size = GetSize(jpeg);
|
||||||
|
return jpeg;
|
||||||
|
}
|
||||||
|
else {
|
||||||
using Image image = Image.Load(input);
|
using Image image = Image.Load(input);
|
||||||
size = image.Size;
|
size = image.Size;
|
||||||
image.Metadata.ExifProfile = null;
|
image.Metadata.ExifProfile = null;
|
||||||
|
|
@ -41,12 +49,9 @@ internal class Jpeg {
|
||||||
});
|
});
|
||||||
return jpegStream.ToArray();
|
return jpegStream.ToArray();
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
using MemoryStream jpegStream = new();
|
catch (UnknownImageFormatException exception) {
|
||||||
input.CopyTo(jpegStream);
|
throw new Exception("Unsupported Image Format", exception);
|
||||||
Byte[] jpeg = jpegStream.ToArray();
|
|
||||||
size = GetSize(jpeg);
|
|
||||||
return jpeg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue