svg icons and FHEMWEB

Begonnen von oliv06, 16 März 2014, 18:27:07

Vorheriges Thema - Nächstes Thema

oliv06

I have a iphone 3GS with iOS 4.3.3
Safari seems not to be able to render SVG icons created by potrace when included in a page generated by FHEMWEB (using icon attribute) : it renders them as a text : "Created by potrace 1.8, written by Peter Selinger 2001-2007"
while :
- it render correctly FHEM SVG graphs,
- it render the SVG icon correctly if addressed directly using its URL (e.g. http://my_fhem/fhem/images/openautomation/it_router.svg )

Difference is icons are coded in the FHEMWEB web page as :
<svg class="icon it_router" preserveAspectRatio="xMidYMid meet" viewBox="0 0 468 318" height="318pt" width="468pt" xmlns="http://www.w3.org/2000/svg" version="1.0">
    <metadata>Created by potrace 1.8, written by Peter Selinger 2001-2007</metadata>
....
</svg>


while graphs have :
<embed width="840" height="420" name="wl_sysmon_cpustat" type="image/svg+xml" src="/fhem/SVG_showLog?dev=wl_sysmon_cpustat&logdev=FileLog_sysmon&gplotfile=SM_CPUStat&logfile=CURRENT&pos=">
    #document
        <!DOCTYPE svg>
        <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg>
</embed>


Questions :
1/ Is there a way to make use of the <img src=""> tag instead ? Perheaps it would be more efficient as images are cached by the browser, too.

2/ If not, a workaround would be to suppress the metadata stuff in all SVG icons: in that case you do not see icons on the iphone but the web page is readable ...
Is there any objection to change the icons in the fhem repository ?



rudolfkoenig

Sorry for the late answer, this task in my TODO was quickly "overwritten" with more important ones.

ZitatIs there a way to make use of the <img src=""> tag instead ?
I was not aware of the fact, that SVGs can be specified as an img src, it was definitely not the case as I started with SVG back in 2008.
Changing the code for the SVG-icons would be definitely a lot of work, as they are now sent "inline". More important is the fact, that this would break FHEMWEB on current iOS devices, as they are not able to open more than one connection to FHEM, this is why they are now forced to use SVG. I suggest to use non-SVG icons on the old device or to exchange it with a newer one.

Zitatworkaround would be to suppress the metadata stuff in all SVG icons
I don't see any point in it, since the image will still not be rendered.
The same can also be achieved with changing the iconPath, so that it won't contain the SVG directories.


oliv06

Thanks for these explanations
Zitat von: rudolfkoenig am 28 März 2014, 14:42:54
I don't see any point in it, since the image will still not be rendered.
The same can also be achieved with changing the iconPath, so that it won't contain the SVG directories.
- the point is that rendering all SVG with "Created by potrace 1.8, written by Peter Selinger 2001-2007" fills the screen and the rest is unreadable. I will try to send a screenshot if it can help to understand. If this text does not appear, the rest of the information will be rendered correctly, and in most cases this is sufficient, even if not ideal
- problem with second option is that I will not get pictures on recent terminals either

rudolfkoenig

I understood your point even before I made my statement.
You have three options:
- do not use the 3GS,
- do not use SVGs
- create separate FHEMWEB-instances for the old and for the new deivces, with different iconPath.

oliv06

I saw in the forum that this behavior also occurs also at least  on some macs
I personaly decided to strip metadata from the svg files in fhem directories and it is an acceptable workaround in my case. I do not see any drawback, and it makes generated pages lighter (you could also strip the comments <!-- Created with Inkscape (http://www.inkscape.org/) --> which are sometimes inserted.
I would suggest to do it in the SVN
Quick and dirty :
MYDIR=/opt/fhem/www/images
for d in fhemSVG  openautomation
do
mkdir $d.new
cd $MYDIR/$d
for f in *.svg
do
   cat $f|perl -0777 -pe 's|(<metadata.*?</metadata>)|$1 =~ /<metadata/?"":$1|gse' > ../$d.new/$f
done
cd $MYDIR
mv $d ../$d.old
mv $d.new $d
done