1

I tried adding a picture directly in css like this:

background-image: url(unsplash.jpg);

The image is around 500kB, but I just realized that since I did this the generated .res file has exploded to around 7Mb. So it seems the photo may get added multiple times, which I guess is a bug, or is there some side-effect I need to be aware of?

I then tried to remove the above line from the CSS, but the .res file size doesn't change so it seems the photo is not removed when the .res file is regenerated. Any suggestions on how to remove the photo?

user1246562
  • 825
  • 5
  • 7
  • It could be that the image is being stored uncompressed: just to check, you could save it as a .bmp file and see what file size that is. If you make a new unsplash.jpg that is 1 pixel, square, perhaps it would replace the current one, at a guess. – Andrew Morton Mar 15 '21 at 22:30

1 Answers1

0

First you can just remove the image then delete the resource file which isn't regenerated from scratch all the time to keep performance tight.

I would suggest opening the file with the designer to see what happened under the hood which is sometimes hard to understand with CSS. See this section of the developer guide Multi-Images vs Regular Images. Essentially what you want is to add:

cn1-source-dpi: 0;

This effectively says your interested in a single image and not a multi-image which is the default. You should generally always use the cn1-source-dpi attribute to define the DPI of your source images as the default might produce images that are too big/small.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • I deleted the .res file, but now I get an error "Updating merge file /Users/user/NetBeansProjects/myapp/target/css/theme.css.merged Exception in thread "main" java.io.FileNotFoundException: /Users/user/NetBeansProjects/myapp/target/css/theme.css.merged (No such file or directory)" and the compile process just seems to get stuck (Netbeans 12.2). I also tried deleting the other temporary files in the css directory but it didn't help. I don't have the 'target' directory, but it's not something I've changed. – user1246562 Mar 16 '21 at 07:31
  • I just deleted the res file and the build directory. Then I did a refresh cn1libs. I didn't delete the css merged. This should cleanup. if the file isn't re-created there might be an error in the CSS (e.g. reference to non-existing image) that prevents the file from being created. – Shai Almog Mar 17 '21 at 02:10