Skip to content

Commit c415b3f

Browse files
committed
Fix: Avoid generating thumbnails of images that are still being extracted (Extractions with 7-Zip)
1 parent 87ac55c commit c415b3f

6 files changed

Lines changed: 64 additions & 41 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1616

1717
- Save image not saving the correct page in manga mode [`b14a26e`](https://github.com/ollm/OpenComic/commit/b14a26eacdc77d37cdeb578fc203438058c7c5e2)
1818
- Sometimes right click on reading fails [`b14a26e`](https://github.com/ollm/OpenComic/commit/1a8e145a997c67494e1a6c70c5f73acee7720000)
19+
- Avoid generating thumbnails of images that are still being extracted (Extractions with 7-Zip)
1920

2021
## [v1.3.1](https://github.com/ollm/OpenComic/releases/tag/v1.3.1) (05-10-2024)
2122

TRANSLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ OpenComic has translations into 17 languages.
128128

129129
[ru.json](https://github.com/ollm/OpenComic/blob/master/languages/ru.json)
130130

131-
`27.3% | Remain 309 | Translated 116`
131+
`100% | Remain 0 | Translated 425`
132132

133133
<a href="https://github.com/ollm/OpenComic/blob/master/languages/ru.json"><img src="https://raw.githubusercontent.com/ollm/OpenComic/master/images/translated/ru.svg" /></a>
134134

images/translated.svg

Lines changed: 1 addition & 1 deletion
Loading

images/translated/ru.svg

Lines changed: 1 addition & 1 deletion
Loading

scripts/image.js

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,60 +20,82 @@ async function resize(fromImage, toImage, config = {})
2020
if(/*inArray(extension, imageExtensions.ico)/* || */inArray(extension, imageExtensions.ico)) // Unsupported images format for resize
2121
return reject({});
2222

23-
sharp(fromImage, {failOn: 'none'}).flatten({background: {r: 255, g: 255, b: 255}}).jpeg({quality: config.quality}).resize(config).toFile(toImage, async function(error) {
24-
25-
if(error && /unsupported image format/iu.test(error?.message || ''))
26-
{
27-
if(!imageMagick) imageMagick = require('gm').subClass({imageMagick: true});
23+
_resize(fromImage, toImage, config, resolve, reject);
2824

29-
imageMagick(fromImage).resize(config.width, null).quality(config.quality).noProfile().write(toImage, function(error){
25+
});
26+
}
3027

31-
if(error)
32-
{
33-
if(!graphicsMagick) graphicsMagick = require('gm').subClass({imageMagick: false});
28+
async function _resize(fromImage, toImage, config = {}, resolve, reject, deep = 0)
29+
{
30+
let options = {}
3431

35-
graphicsMagick(fromImage).resize(config.width, null).quality(config.quality).noProfile().write(toImage, async function(error){
32+
if(deep > 3)
33+
options = {failOn: 'none'};
3634

37-
if(error)
38-
{
39-
if(jimp === false) jimp = require('jimp').Jimp;
35+
sharp(fromImage, options).flatten({background: {r: 255, g: 255, b: 255}}).jpeg({quality: config.quality}).resize(config).toFile(toImage, async function(error) {
4036

41-
try
42-
{
43-
const jimpImage = await jimp.read(fromImage);
44-
await jimpImage.resize({w: config.width}).write(toImage, {quality: config.quality});
37+
if(error && /unsupported image format/iu.test(error?.message || ''))
38+
{
39+
if(!imageMagick) imageMagick = require('gm').subClass({imageMagick: true});
4540

46-
resolve(toImage);
47-
}
48-
catch(error)
49-
{
50-
reject(error);
51-
}
52-
}
53-
else
41+
imageMagick(fromImage).resize(config.width, null).quality(config.quality).noProfile().write(toImage, function(error){
42+
43+
if(error)
44+
{
45+
if(!graphicsMagick) graphicsMagick = require('gm').subClass({imageMagick: false});
46+
47+
graphicsMagick(fromImage).resize(config.width, null).quality(config.quality).noProfile().write(toImage, async function(error){
48+
49+
if(error)
50+
{
51+
if(jimp === false) jimp = require('jimp').Jimp;
52+
53+
try
5454
{
55+
const jimpImage = await jimp.read(fromImage);
56+
await jimpImage.resize({w: config.width}).write(toImage, {quality: config.quality});
57+
5558
resolve(toImage);
5659
}
57-
});
60+
catch(error)
61+
{
62+
reject(error);
63+
}
64+
}
65+
else
66+
{
67+
resolve(toImage);
68+
}
69+
});
5870

59-
}
60-
else
61-
{
62-
resolve(toImage);
63-
}
64-
});
65-
}
66-
else if(error)
71+
}
72+
else
73+
{
74+
resolve(toImage);
75+
}
76+
});
77+
}
78+
else if(error)
79+
{
80+
if(deep > 3)
6781
{
6882
console.error(fromImage, error);
6983
reject(error);
7084
}
7185
else
7286
{
73-
resolve(toImage);
74-
}
75-
});
87+
deep++;
88+
89+
console.error('Error: '+(deep > 3 ? 'Trying once more' : 'Trying again')+' in '+(100 * deep)+'ms'+(deep > 3 ? ' with failOn: none' : '')+' | '+fromImage, error);
7690

91+
await app.sleep(100 * deep);
92+
_resize(fromImage, toImage, config, resolve, reject, deep);
93+
}
94+
}
95+
else
96+
{
97+
resolve(toImage);
98+
}
7799
});
78100
}
79101

themes/material-design/actions.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@
931931
width: 50% !important;
932932
left: 50% !important;
933933
max-width: 640px;
934-
transform: translateY(-50%) translateX(-50%) !important;
934+
transform: translateY(-50%) translateX(-50%) !important; /*! Keep this line */
935935
transform: translateY(round(-50%, 1px)) translateX(round(-50%, 1px)) !important;
936936
padding: 0px;
937937
border-radius: 24px;

0 commit comments

Comments
 (0)