kimmknight/raweb

Dynamic PNG/ICO delivery

Closed this issue · 4 comments

Apparently, using System.Drawing, we can extract the contents of a PNG and convert it to an ICO, and extract different sized icons from an ICO and output them as PNG. It can also scale images up and down.

It would be really nice if an RAWeb user only had to worry about adding a single PNG, and the 32px, 64px, and ICO file were automatically generated from that. Likewise, if the user only adds an ICO file, the PNG images could be generated from that.

I've put together a prototype image converter/resizer for .NET 4.8.

It's called get-image.aspx and it requires 2 query parameters: imagefile and format

Example:

http://myserver.local/get-image.aspx?imagefile=Microsoft Excel.ico&format=png

imagefile is any file that exists in a subfolder called images.
format defines the output format and can be: png, png32, ico

It will respond with the image in the desired output format, with the correct MIME type set.

If imagefile is provided with no file extension, for example:

http://myserver.local/get-image.aspx?imagefile=Microsoft Excel&format=png

It will look for an ICO file first and deliver that (in the desired format) if present. If an ICO doesn't exist with that name, it will look for a PNG to serve.

get-image3.zip

I think it should be fairly easy to integrate this with RAWeb's Web Interface and Webfeed. It would however mean a change to the folder structure: Instead of having separate icon, icon32, png folders, there would just be an images folder. I think this would be a good thing!

for simplicity I think it would also make sense putting everyhing in a resource folder (I mean .ico and .rdp). This way both files stay together and when using your remoteapptool when saving the rdp file no different folder for the exported .ico needs to be selected (and it is obvious if there is a typo in the filename)

for simplicity I think it would also make sense putting everyhing in a resource folder (I mean .ico and .rdp)

I definitely agree. I've just pushed the dynamic images feature to a new branch called next. In the process, I changed all the icon/png/rdp paths to a common folder called resources.

There is one issue - When converting a PNG to an ICO, the ICO ends up with a low bit depth. This is an annoyance only when subscribing to the webfeed using RemoteApp and Desktop Connections and using PNGs exclusively for icons. The workaround is to always use ICOs and only use PNGs as a last resort.

With the recent update to auth, upcoming reimplementation of multi-user, removing the icon folders, allowing subfolders, having the web interface consume webfeed xml, and removing the ASP version, the wiki documentation and readme will need to be updated. I was thinking to use the next branch for adding these new features. Once happy with their implementation, update the docs and readme, and merge back into master.

Resolved in commit 3dd8fab