-
Notifications
You must be signed in to change notification settings - Fork 36
Add docker support, fix smaller dependency issues in javascript and fix outdated "flattenImage" method #11
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
4aeed19
23e4764
64c657f
834edac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| FROM php:7.3-apache | ||
| RUN echo "deb http://http.debian.net/debian/ buster main contrib non-free" > /etc/apt/sources.list && \ | ||
| echo "deb http://http.debian.net/debian/ buster-updates main contrib non-free" >> /etc/apt/sources.list && \ | ||
| echo "deb http://security.debian.org/ buster/updates main contrib non-free" >> /etc/apt/sources.list && \ | ||
| apt-get update | ||
| RUN apt-get install -y --no-install-recommends \ | ||
| imagemagick \ | ||
| ghostscript \ | ||
| libmagickwand-dev \ | ||
| librsvg2-bin \ | ||
| xfonts-100dpi \ | ||
| xfonts-75dpi \ | ||
| xfonts-base \ | ||
| fonts-roboto \ | ||
| fonts-inconsolata \ | ||
| ttf-mscorefonts-installer \ | ||
| fonts-open-sans \ | ||
| fontconfig | ||
| COPY server/fontconfig/* /etc/fonts/conf.d/ | ||
| RUN fc-cache -f -v | ||
| RUN printf "\n" | pecl install imagick | ||
| RUN mkdir -p /tmp | ||
| RUN chmod a+rw /tmp | ||
|
|
||
| RUN docker-php-ext-enable imagick |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| version: "3" | ||
| networks: | ||
| web: | ||
| driver: "bridge" | ||
| services: | ||
| wifi-display: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| volumes: | ||
| - "./server:/var/www/html" | ||
| ports: | ||
| - "80:80" | ||
| networks: | ||
| - "web" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?xml version="1.0"?> | ||
| <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> | ||
| <fontconfig> | ||
|
|
||
| <match target="pattern" > | ||
| <!-- autohint was the old automatic hinter when hinting was patent | ||
| protected, so turn it off to ensure any hinting information in the font | ||
| itself is used, this is the default --> | ||
| <edit mode="assign" name="autohint"> <bool>false</bool></edit> | ||
|
|
||
| <!-- hinting is enabled by default --> | ||
| <edit mode="assign" name="hinting"> <bool>false</bool></edit> | ||
|
|
||
| <!-- for the lcdfilter see http://www.spasche.net/files/lcdfiltering/ --> | ||
| <edit mode="assign" name="lcdfilter"> <const>lcdnone</const></edit> | ||
|
|
||
| <!-- options for hintstyle: | ||
| hintfull: is supposed to give a crisp font that aligns well to the | ||
| character-cell grid but at the cost of its proper shape. | ||
| hintmedium: poorly documented, maybe a synonym for hintfull. | ||
| hintslight is the default: - supposed to be more fuzzy but retains shape. | ||
| hintnone: seems to turn hinting off. | ||
| The variations are marginal and results vary with different fonts --> | ||
| <edit mode="assign" name="hintstyle"> <const>hintnone</const></edit> | ||
|
|
||
| <!-- antialiasing is on by default and really helps for faint characters | ||
| and also for 'xft:' fonts used in rxvt-unicode --> | ||
| <edit mode="assign" name="antialias"> <bool>false</bool></edit> | ||
|
|
||
| <!-- subpixels are usually rgb, see | ||
| http://www.lagom.nl/lcd-test/subpixel.php --> | ||
| <edit mode="assign" name="rgba"> <const>rgb</const></edit> | ||
|
|
||
| <!-- thanks to the Arch wiki for the lcd and subpixel links --> | ||
| </match> | ||
|
|
||
| </fontconfig> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,6 @@ static function getRender($widget_name, $settings, $ws, $hs) { | |
| // Image rendering stuff | ||
|
|
||
| function renderSVG($id) { | ||
| header('Content-type: image/svg+xml'); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why removing the content type? I guess it might still work but I also don't see the reason for it. Is this wrong in any way?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I actually planned to investigate a bit more why this causes a problem. My current assumption is: rendering the bitmap formats also calls this function. Setting the header here writes the header 'Content-type: image/svg+xml' into the png/proprietary bitmap output stream. If I don't remove this line the bitmap is not displayed on the home screen of the admin page. Probably the header(..) call should be moved to the place where svg, png and proprietary bitmap are processed.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Errr good catch! Yeah this should indeed be moved in that case.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error is exactly the reason, why I had to remove the line. If the line is present the preview image cannot be rendered, because of the error you mentioned
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, makes sense. I guess my php.ini doesnt enable warnings on the page (you can disable that to the php error log where it belongs). Not nice that users can see whats going on :P |
||
|
|
||
| // Read the screen and parse it as JSON | ||
| $scr = file_get_contents("screens/".$id); | ||
|
|
@@ -108,7 +107,7 @@ function renderBMP($id, $numc, $maxwidth, $maxheight) { | |
| $im->transformImageColorspace(imagick::COLORSPACE_GRAY); | ||
| $im->posterizeImage($numc, imagick::DITHERMETHOD_NO); | ||
| $im->setImageBackgroundColor('white'); | ||
| $im = $im->flattenImages(); | ||
| $im = $im->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN); | ||
| unlink($svgf); | ||
| unlink($svgf.".png"); | ||
| return $im; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How's this file loaded and used?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me quite a while to get it to run. This file is copied into the docker container. The command
RUN fc-cache -f -v`in Dockerfile then processes it. All linux processes working with fonts then use these hints to do the font rendering, including PHP/Imagemagick.
Here is some more information about fc-cache/fontconfig: https://linux.die.net/man/1/fc-cache
And the result of the file is that the fonts are rendered without antialiasing which results in more crisp text. In a display with gray scales antialiasing is great but on a pure black & white display it is distorting the text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah so it's a docker specific thing. Gotcha!