Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading image to project file can cause mismatched file type #8387

Open
shotgunanaconda opened this issue Jan 13, 2025 · 2 comments
Open

Loading image to project file can cause mismatched file type #8387

shotgunanaconda opened this issue Jan 13, 2025 · 2 comments
Assignees

Comments

@shotgunanaconda
Copy link

shotgunanaconda commented Jan 13, 2025

Problem description

Construct does not update icons at all after importing new icons, setting them to app icon, exporting to nwjs/webview and using the windowsiconupdater.

Attach a .c3p

icon test.zip

Steps to reproduce

open, export and run icon .exe.

Observed result

it removes default icon in case of nwjs and nothing with webview, although it gives the correct confirmationo.

Expected result

Change icon.

More details

Personally I need this fixed urgently since we are submitting for steam NextFest in february. I only use Stables and no betas for safety.

Affected browsers/platforms:

Using latest Stable.

@AshleyScirra AshleyScirra changed the title Windows Icon Updater doesn't work in latest stable (WebView & NWJS) Loading image to project file can cause mismatched file type Jan 13, 2025
@AshleyScirra
Copy link
Member

AshleyScirra commented Jan 13, 2025

The problem here is actually that the project icon files are JPEG files, which does not match the .png file extension the files use. The Windows Icon Updater works correctly if given PNG files, but it does not support using JPEG files (IIRC because Windows doesn't support JPEG data for icons). To work around this you can save to a project folder, use an external image editor like Paint.NET to load the icon files and save-as in PNG format, and then copy those files over the existing icon files in the project folder.

The real question is why you'd end up with JPEG files with the .png file extension, and I think this relates to a change in r409 (Animations editor: imported lossy images are now preserved in their original format in the project until modified). It is by design that if you do something like import a JPEG file for a Sprite animation frame, Construct keeps that animation frame's file in JPEG format, and only converts it to PNG if you edit it. However it looks like this is inappropriately applied to project files like icons - presumably you edited the icon in Construct and imported a JPEG image, and Construct used the JPEG file data in place of a file with a .png file extension, which is incorrect - in this case it should maintain the encoding of the file extension.

So assigning to @DiegoScirra to fix - steps to reproduce are:

  1. Create a new empty project and save to a folder
  2. Edit an icon file in the project bar
  3. Click 'Open' in the toolbar and choose a JPEG image with the same size as the existing image
  4. Close and save the project
  5. Examine the format of the image file in the project folder

To check the real encoding format, open the image in Notepad (or some other text editor). PNG images include the characters "PNG" in the first few bytes; JPEG images include "JFIF" in the first few bytes.

In general, editing an image from a project file must preserve the encoding according to the file extension - e.g. if you open a .webp project file and import a PNG, it should also save the data as WebP, etc.

@shotgunanaconda
Copy link
Author

shotgunanaconda commented Jan 13, 2025

Thank you @AshleyScirra !

For information, and it only hit me after your post, how i created these icons are I have a .jpg image that i used an automated webservice (https://www.appicon.co/#app-icon) to create the different sizes. it seems like that site converted them to the faulty .pngs.

I opened all icons in photoshop and quickly re-exported them as png's and now it works.

I hope that information helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants