Closed fusefib closed 2 months ago
This is problem Qt6, not STEX!
@fusefib It looks like Qt6 build needs to be recompiled with this https://doc.qt.io/qt-6/qimagereader.html#setAllocationLimit function called with 0 (or something large enough)
@plzombie , а где баг то? STEX не падает. А не "читает" изображение Qt6.
@zvezdochiot Ну технически это регрессия с переходом на Qt6, так как теперь изображения по умолчанию могут весить не более 128MB, и надо ставить #ifdef QT6
в main и вызывать функцию, которая возвращает всё обратно или вообще убирает ограничение
@plzombie , а баг то где? Где падение, переполнение, либо уб? Спам это, а не баг.
@zvezdochiot Баг в том, что у него в Qt6 не открываются большие изображения. И фиксить это надо не на стороне Qt6, а на стороне STEX, добавив вызов функции, убирающей ограничения
@plzombie say:
Баг в том, что
@zvezdochiot say:
Где падение, переполнение, либо уб?
@zvezdochiot Хочешь чтобы падало? Попробуй изображение со стороной 65500 загрузить. Я тут ещё один баг могу подкинуть. Программа не разделяет несколько файлов с одинаковым именем, но разным расширением (8193.jpg, 8193.png, 8193.tif). В папке out один файл на три изображения (и кэш у них тоже один). Ещё падает, если один и тот же файл два раза добавляешь
@fusefib Please try this build staging.zip
@plzombie say:
Попробуй изображение со стороной 65500 загрузить.
Попробую. Только 65500/215мм*25,4=7738dpi
(сюр какой то).
@plzombie say:
Программа не разделяет несколько файлов с одинаковым именем.
Это не баг.
@plzombie say:
Ещё падает, если один и тот же файл два раза добавляешь.
Вот это уже не хорошо. Но связываться с итераторами не хочется, а как сделать "по-иначе" я не соображу.
Thank you, the new build works. So did changing the environment variable - 256
MB was the default or equivalent, and higher value improved things.
Apologies for the 'bug' wording. STEX's handling of the Qt6 upstream change was good considering the situation - no instability, no crash. I'm testing Qt6 builds specifically because I know Qt6 can create problems.
The same-filename collision also occurs if you subsequently load an image with the same filename (and extension) from a different folder; I used it at some point or another to pick a re-scan and then select the better photo and delete the other. The interface works, and this functionality is useful as-is if the user knows what's going on.
Description: The limitation described only affects Qt6 builds, not regular builds. I've conducted testing on Windows builds ranging from
0.2023.10.24-X86-64-Qt6
to0.2024.05.09-X86-64-Qt6
, and all Qt6 versions exhibit the same behavior. This constraint specifically impacts JPEG and PNG files, while TIFF files remain unaffected. For JPEGs and PNGs, the canvas is restricted to 2^26 or 67,108,864 pixels. In other words, for JPEGs and PNGs:TIFFs, on the other hand, load without any issues regardless of their pixel count (at least within "reasonable" limits, I tested 20000x20000 and could output bitonal with ScanTailor-Experimental Qt6 just fine).
Expected Behavior: These images should load as in normal (Qt5?) builds.
I would add that these resolutions can be encountered in real-life. I came across this issue with a 600dpi scan of a large magazine via a RICOH MP C3004ex device, which resulted in 7016x9921 JPEG files (double page scans, likely A3 size @ 600dpi).
If it's a permanent limitation owing to Qt6, perhaps a better warning message should be given here (see below).
Actual Behavior: When trying to load a JPEG or PNG whose pixel count is 67,108,865 (2^26+1) pixels or more, it doesn't display or work with the image, and we see the following vague warning message instead:
The following file could not be loaded: {the file path}
Environment:
0.2024.05.09-X86-64-Qt6
(but issue existed in the first Qt6 build0.2024.05.09-X86-64-Qt6
)Steps to reproduce:
pip install Pillow
resize_img.py
:def resize_image(input_image, output_image, dimensions, quality): image = Image.open(input_image) resized_image = image.resize(dimensions, Image.LANCZOS) if output_image.endswith(".png"): resized_image.save(output_image) elif output_image.endswith(".tif"): resized_image.save(output_image, compression="tiff_deflate") else: resized_image.save(output_image, quality=quality)
if name == "main": parser = argparse.ArgumentParser(description='Resize an image to arbitrary dimensions.') parser.add_argument('input', help='Input image file') parser.add_argument('--dimensions', required=True, help='Desired dimensions in the format "XxY"') parser.add_argument('--quality', type=int, default=80, help='Output quality (0-100 for JPEG, ignored for PNG and TIFF)') parser.add_argument('--output-png', action='store_true', help='Output image as PNG (default is JPEG)') parser.add_argument('--output-tif', action='store_true', help='Output image as TIFF') args = parser.parse_args()
python resize_img.py --dimensions 8192x8192 input.jpg python resize_img.py --dimensions 8192x8192 input.jpg --output-tif python resize_img.py --dimensions 8192x8192 input.jpg --output-png python resize_img.py --dimensions 8192x8193 input.jpg python resize_img.py --dimensions 8192x8193 input.jpg --output-tif python resize_img.py --dimensions 8192x8193 input.jpg --output-png