Skip to content

Commit

Permalink
When reading images for export, we would read the images twice for no…
Browse files Browse the repository at this point in the history
…thing.

Should mean faster export when convertion doesn't change the type. Introduced in PR #91.

Exporting files should never have hit the part of the code fixed in 2562db5, only when reading a file.

Reconverting images in webp, djvu, heif or avif would convert them all to jpeg when exporting anyway needlessly.
  • Loading branch information
maforget committed Aug 26, 2024
1 parent 2562db5 commit 080168a
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions ComicRack.Engine/IO/Provider/StorageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,30 +204,33 @@ public static PageResult[] GetImages(IImageProvider provider, ComicPageInfo cpi,
StoragePageType storagePageType = (setting.PageType != StoragePageType.Original) ? setting.PageType : GetStoragePageTypeFromExtension(ext);
if (!string.IsNullOrEmpty(ext) && setting.PageResize == StoragePageResize.Original && (setting.PageType == StoragePageType.Original || setting.PageType == GetStoragePageTypeFromExtension(ext)) && cpi.Rotation == ImageRotation.None && setting.DoublePages == DoublePageHandling.Keep && setting.ImageProcessing.IsEmpty)
{
array = provider.GetByteImage(cpi.ImageIndex);
if (setting.PageType == StoragePageType.Jpeg)
{
using (MemoryStream s = new MemoryStream(array))
{
if (!JpegFile.GetImageSize(s, out var size))
{
array = null;
}
else
{
cpi.ImageWidth = size.Width;
cpi.ImageHeight = size.Height;
}
}
if (forExport)
{
ExportImageContainer data = provider.GetByteImageForExport(cpi.ImageIndex);
array = (data.NeedsToConvert) ? ConvertImage(storagePageType, data.Bitmap, setting) : data.Data;
}

if (forExport)
else
{
ExportImageContainer data = provider.GetByteImageForExport(cpi.ImageIndex);
array = (data.NeedsToConvert) ? ConvertImage(storagePageType, data.Bitmap, setting) : data.Data;
}
array = provider.GetByteImage(cpi.ImageIndex);
}

if (setting.PageType == StoragePageType.Jpeg)
{
using (MemoryStream s = new MemoryStream(array))
{
if (!JpegFile.GetImageSize(s, out var size))
{
array = null;
}
else
{
cpi.ImageWidth = size.Width;
cpi.ImageHeight = size.Height;
}
}
}

if (array != null && array.Length != 0)
if (array != null && array.Length != 0)
{
return new PageResult[1]
{
Expand Down

0 comments on commit 080168a

Please sign in to comment.