failed to resample image

Linux related discussion about netjukebox
Locked
CasN
User
Posts: 13
Joined: Thu Nov 02, 2023 11:36 am
Location: Netherlands

failed to resample image

Post by CasN »

When updating the database, i get the message:
image_2023-11-02_114827528.png
image_2023-11-02_114827528.png (12.44 KiB) Viewed 40713 times
What can I do to overcome this error?
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: failed to resample image

Post by wbartels »

Here is the code that created the error message:

Code: Select all

$extension = strtolower(substr(strrchr($image, '.'), 1));

if		($extension == 'jpg')	$src_image = @imageCreateFromJpeg($image)	or message(__FILE__, __LINE__, 'error', '[b]Failed to resample image:[/b][br]' . $image);
elseif	($extension == 'png')	$src_image = @imageCreateFromPng($image)	or message(__FILE__, __LINE__, 'error', '[b]Failed to resample image:[/b][br]' . $image);
else																		message(__FILE__, __LINE__, 'error', '[b]Failed to resample image:[/b][br]Unsupported extension.');
I think that one of the two reason created the error:
  • The file with the jpg extension isn't a jpg file
  • The jpg file is corrupted
A simple solution would be to replace the image file.
If this doesn't help send me the cover.jpg file by private message for examination.

Success CasN!
CasN
User
Posts: 13
Joined: Thu Nov 02, 2023 11:36 am
Location: Netherlands

Re: failed to resample image

Post by CasN »

Hi Waldo,
that was the issue, it appeared to be a png-file. So a question of renaming and on to the next.
Thanks so far (bedankt!),
Cas
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: failed to resample image

Post by wbartels »

CasN wrote: Fri Nov 03, 2023 10:56 am Hi Waldo,
that was the issue, it appeared to be a png-file. So a question of renaming and on to the next.
Thanks so far (bedankt!),
Cas
Your welcome, graag gedaan ;-)
I will add image file validation on the next release!
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: failed to resample image

Post by wbartels »

This update creates a more meaningfull error message in the include/library_message.inc.php script around line 100

Code: Select all

if		($extension == 'jpg')	$src_image = @imageCreateFromJpeg($image)	or message(__FILE__, __LINE__, 'error', '[b]Failed to resample[/b][br]This is not a vallid JPG image:[br]' . $image);
elseif	($extension == 'png')	$src_image = @imageCreateFromPng($image)	or message(__FILE__, __LINE__, 'error', '[b]Failed to resample[/b][br]This is not a vallid PNG image:[br]' . $image);
else																		message(__FILE__, __LINE__, 'error', '[b]Failed to resample[/b][br]Unsupported or corrupted image:[br]' . $image);
CasN
User
Posts: 13
Joined: Thu Nov 02, 2023 11:36 am
Location: Netherlands

Re: failed to resample image

Post by CasN »

I have replaced the existing code with these lines (hope I do not need it anymore :D ).
CasN
User
Posts: 13
Joined: Thu Nov 02, 2023 11:36 am
Location: Netherlands

Re: failed to resample image

Post by CasN »

Also noticed that in case a cover image in not present, Netjukebox tries to obtain from the MP3 itself. Under windows the file extracted is not usable hence the update process stops. In my view the process should continue and the album should be added to the onces that need additional attention.
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: failed to resample image

Post by wbartels »

CasN wrote: Sat Nov 11, 2023 4:28 pm Also noticed that in case a cover image in not present, Netjukebox tries to obtain from the MP3 itself. Under windows the file extracted is not usable hence the update process stops. In my view the process should continue and the album should be added to the onces that need additional attention.
Thanks, I will look in this later.
Maybe you are willing to help me because I haven't a Windows (virtual) computer.
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: failed to resample image

Post by wbartels »

CasN wrote: Sat Nov 11, 2023 4:28 pm Also noticed that in case a cover image in not present, Netjukebox tries to obtain from the MP3 itself. Under windows the file extracted is not usable hence the update process stops. In my view the process should continue and the album should be added to the onces that need additional attention.
It could be that only on Windows the helper apps from getID3() are needed.
You can download the complete getID3() v1.9.16 (with helper apps) from:
https://github.com/JamesHeinrich/getID3 ... 1.9.16.zip
Would you be so kind to test it with the 1.9.16 package?
If it works you can of course try the latest 1.9.xx package.

On a live environment I should always delete the demo directory.
It is also save to delete the getid3/extension.cache.xxx.php files.
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: failed to resample image

Post by wbartels »

CasN wrote: Sat Nov 11, 2023 4:28 pm Also noticed that in case a cover image in not present, Netjukebox tries to obtain from the MP3 itself. Under windows the file extracted is not usable hence the update process stops. In my view the process should continue and the album should be added to the onces that need additional attention.
It is possible to (temporary) disable the image extraction in the config.inc.php file:

Code: Select all

$cfg['image_read_embedded']            = false;
CasN
User
Posts: 13
Joined: Thu Nov 02, 2023 11:36 am
Location: Netherlands

Re: failed to resample image

Post by CasN »

I tried first adding the Windows helper apps, no luck. Next I downloaded the latest GetID3 and moved the downloaded helper apps to the bin directory, no luck. Next I switched of reading the embedded and this clearly worked.
I also have a folder image which I can use as the front cover so i am all set.

Windows is a system I use for day to day work (and trying out new software as well), my websites are under Ubuntu (where it is working without issues).
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: failed to resample image

Post by wbartels »

CasN wrote: Mon Nov 13, 2023 1:54 pm I tried first adding the Windows helper apps, no luck. Next I downloaded the latest GetID3 and moved the downloaded helper apps to the bin directory, no luck. Next I switched of reading the embedded and this clearly worked.
I also have a folder image which I can use as the front cover so i am all set.

Windows is a system I use for day to day work (and trying out new software as well), my websites are under Ubuntu (where it is working without issues).
Thanks for the help and infos!
getID3() has its own directory for helperapps (without a bin directory): netjukebox/lib/getid3/helperapps/
I know it is confusing with also a netjukebox helper app directory, sorry ;-)
Could you try it again and place the getID3() helper apps in netjukebox/lib/getid3/helperapps/

Thanks!
CasN
User
Posts: 13
Joined: Thu Nov 02, 2023 11:36 am
Location: Netherlands

Re: failed to resample image

Post by CasN »

Ok, tried that also but still get the same error message. I have attaached the (extracted) jpg file that is causing the issue
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: failed to resample image

Post by wbartels »

Now I can reproduce the error message on Windows.
The same flac file with embedded jpg image extract correctly on Ubuntu.
These are the same findings you described.

If I have time again I will look into it.
For the meantime Windows users can disable reading embedded images:

Code: Select all

$cfg['image_read_embedded']            = false;
PS
It dit took me a while to install Windows 11 ARM64 on a Mac mini M2.
With trail and error I discovered UTM and that did the trick.
https://docs.getutm.app/guides/windows/
The installation is much smoother than in the above guide.
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Moved

Post by wbartels »

I will lock this topic because the first section has been a fix.
And the second section is moved to Windows related
Locked