Author Topic: Dual-Image Problem  (Read 2987 times)

0 Members and 1 Guest are viewing this topic.

Offline thuman5

  • Member
  • *
  • Posts: 12
    • tkhuman.com
Dual-Image Problem
« on: November 26, 2018, 08:20:48 AM »
Most of my dual-Image icons do not seem to display for the forecast and current conditions. Just get text. when I attempt to bring up what the page is trying to bring up for one of the icons, I get the following error;  fatal error: Uncaught Error: Call to undefined function imagettfbbox() in /vdb/home/vh2311/www/tkhuman.com/DualImage.php:452 Stack trace: #0 /vdb/home/vh2311/www/tkhuman.com/DualImage.php(413): calculateTextBox('80%', './forecast/icon...', 11, 0) #1 /vdb/home/vh2311/www/tkhuman.com/DualImage.php(287): add_PoP(Resource id #10, 'L', '80', Resource id #9, './forecast/icon...') #2 {main} thrown in /vdb/home/vh2311/www/tkhuman.com/DualImage.php on line 452    ????
Any help would be appreciated since my pages are a mess because of the non-displaying images.

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 947
    • LexMAWeather
Re: Dual-Image Problem
« Reply #1 on: November 26, 2018, 09:43:44 AM »
imagettfbbox() is a PHP function. This indicates that your host doesn't support it (???).

Have to run but can look at this more later if someone else doesn't figure it out.

https://secure.php.net/manual/en/function.imagettfbbox.php

Also, this post should go in the Weather Website PHP/AJAX scripting area - Ken will likely move it for you.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Dual-Image Problem
« Reply #2 on: November 26, 2018, 09:49:19 AM »
Your host
Quote
Webserver OS: Linux hosting3.dnsexit.com 2.6.32-642.4.2.el6.i686 #1 SMP Tue Aug 23 19:20:20 UTC 2016 i686
PHP Version: 7.2.11
Document root: /home/vh2311/www/tkhuman.com/
allow_url_fopen = ON
allow_url_include = off
Stream support for http is available
Stream support for https is NOT available but REQUIRED.

Current GD (image handling functions) status:

    GD support: is available.
    GD Version: bundled (2.1.0 compatible)
    FreeType Support: is NOT available
    GIF Read Support: is available
    GIF Create Support: is available
    JPEG Support: is available
    PNG Support: is available
    WBMP Support: is available
    XPM Support: is NOT available
    XBM Support: is available
    WebP Support: is NOT available
    BMP Support: is available
    JIS-mapped Japanese Font Support: is available
seems incomplete (missing HTTPS support and GD FreeType support).  I think the latter is the cause of the undefined function imagettfbbox() function which should be a part of the GD package.  Contact your webhoster tech support and ask them to fix the PHP installation (you'll need HTTPS stream support, and the FreeType support in GD libarary).
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 947
    • LexMAWeather
Re: Dual-Image Problem
« Reply #3 on: November 26, 2018, 10:43:31 AM »
In the meantime, I believe that if you go into advforecast2.php and un-comment the second line here:

Code: [Select]
$DualImageAvailable = file_exists("./DualImage.php")?true:false;
#$DualImageAvailable = false;

you should be able to get it to work with the basic images.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Dual-Image Problem
« Reply #4 on: November 26, 2018, 11:14:37 AM »
True, however getting GD functionality fixed in PHP is the longer term solution.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 947
    • LexMAWeather
Re: Dual-Image Problem
« Reply #5 on: November 26, 2018, 11:53:45 AM »
True, however getting GD functionality fixed in PHP is the longer term solution.

Definitely. I should have emphasized that this is just a work-around until the real fix can be done.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: Dual-Image Problem
« Reply #6 on: November 27, 2018, 10:42:42 AM »
Ken, I have also been having some problems with the 'imagettfbbox' function. I am getting the error that the font file cannot be found even if the font file is located into the same folder as the PHP script. I have searched the Web for a solution ... but I am still having the same error message.

For example, the results of the GD test are:
Code: [Select]
GD is supported by your server!
GD Version              Yes
FreeType Support        Yes
FreeType Linkage        Yes
GIF Read Support        Yes
GIF Create Support      Yes
JPEG Support            Yes
PNG Support             Yes
WBMP Support            Yes
XPM Support             Yes
XBM Support             Yes
WebP Support            Yes
BMP Support             Yes
JIS-mapped Japanese Font Support No

The problems I am having with 'imagettfbbox' function are on my development computer running XAMPP with the latest version of PHP (ie: 7.2.12 Win32 VC15 x86 thread-safe) (no external access).

I thought that for some reasons, PHP might not have been compiled with freetype support (--with-freetype-dir=DIR ). But then, doing a PHP Info and under the 'gp' results, the following is displayed:
Code: [Select]
GD Support          enabled
GD Version          bundled (2.1.0 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.9.1

I even tried many of the examples posted in the PHP manual and get the same 'Could not find/open font' error.

I cannot remember when that situation started.

I also tried another server software, the Abyss Web Server with PHP version 7.2.8 and got the same 'Could not find/open font' error message. It seems that my whole computer might be 'allergic' to the GD functions...  :sad:

Any suggestion as to where I should look for, maybe, a PHP setting or an Apache setting that might be causing this problem?
R_o_B
---
eMail: weather@herray.net

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Dual-Image Problem
« Reply #7 on: November 27, 2018, 11:52:56 AM »
Hi Ray,

That's odd .. the imagettfbox() function has been in PHP (GD) since PHP 4.

On my main PHP 7.2.12 system it shows:
Code: [Select]
GD Support     enabled
GD Version     bundled (2.1.0 compatible)
FreeType Support     enabled
FreeType Linkage     with freetype
FreeType Version     2.3.11
GIF Read Support     enabled
GIF Create Support     enabled
JPEG Support     enabled
libJPEG Version     6b
PNG Support     enabled
libPNG Version     1.2.49
WBMP Support     enabled
XPM Support     enabled
libXpm Version     30411
XBM Support     enabled
on my XAMPP test system with PHP 7.1.9 it shows:
Code: [Select]
GD Support     enabled
GD Version     bundled (2.1.0 compatible)
FreeType Support     enabled
FreeType Linkage     with freetype
FreeType Version     2.8.0
GIF Read Support     enabled
GIF Create Support     enabled
JPEG Support     enabled
libJPEG Version     9 compatible
PNG Support     enabled
libPNG Version     1.6.29
WBMP Support     enabled
XPM Support     enabled
libXpm Version     30512
XBM Support     enabled
WebP Support     enabled
and both work just fine with DualImage.php functions.

I see your FreeType version is 2.9.1 (while mine are  2.3.11 and 2.8.0).  I did a quick search on the PHP Bug list and found https://bugs.php.net/bug.php?id=75656 that may be related (or not).
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: Dual-Image Problem
« Reply #8 on: November 28, 2018, 07:21:14 AM »
Ken, what is really odd is that I have tried the same scripts/examples in an other server software, the Abyss Web Server with PHP version 7.2.8 and get the same error. That is why I am confused as to what is causing the error.

I have read the thread on the PHP Bug list and it seems that there is indeed a problem somewhere in PHP.

Since I have version 7.1.5 up to version 7.2.12 of PHP installed (or ZIPped) in my development XAMPP folder, I have already tried going back a few versions but, it seems, the problem remains.

I will try to go to even older version of PHP and if the error does not go away, I will even try to go back to older (or ZIPped) versions of XAMPP!

Another oddity: I have a home/office server (different computer than my development computer) running XAMPP version 7.2.2 (ie: Apache version 2.4.29) and PHP version 7.2.3 and I get the same error!

I was also thinking that there might be something in the operating system, the 'wonderful' Windows 10 PRO (being very very sarcastic here  :evil: ), something with one of its past updates, but the version running on my development  computer is different (an older version 1703 build 15063.1387) than the one running on my home/office server (newer version 1709 build 16299.665).

Fortunately, the PHP script that first showed the problem can be used once the True Type Font option has been deactivated.

I am getting too old for this kind of stuff...  :oops: ...It is probably time for my 71+ year old mind and body to retire from programming, disconnect from the Internet and move away from civilization, somewhere where the air is still clean and fresh, somewhere where water still taste like ... well, water, without any additives, somewhere where vegetables are still grown without chemicals, somewhere where trees are still green, mighty and plentiful... I guess I will have to move to another planet ... or the promise land...  :roll:
R_o_B
---
eMail: weather@herray.net

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Dual-Image Problem
« Reply #9 on: November 29, 2018, 01:45:39 PM »
Dang Ray, your systems do seem to have a small curse on them ...

Could it be that your XAMPP / PHP installs are in directories that have embedded spaces in the names?

My XAMPP is in c:\xampp\  and working as expected.  My 1and1 PHP install has (for the configure command)

'--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext'

set. 
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: Dual-Image Problem
« Reply #10 on: November 29, 2018, 05:55:04 PM »
Thank you for the reply, Ken.

Neither the main directory (or folder) nor any of the sub-directories contain spaces:
- the main directory where the XAMPP server software has been installed is 'E:\xampp\'
- the main directory where the domain names are located is 'E:\htdocs\'
- the sub-directory where the HTML/PHP scripts are located is 'E:\htdocs\tzweather'

The arrangement/organization of the main directory and sub-directories has been the same for the past 10+ years without problem.

At one time in the past (might be days, might be week, might be months) the misbehaving PHP script was operating without error as it has been part of my experimental (under development) Web site.

I have already spent too many hours searching the Web for that stupid error...  ](*,)

Just for the fun of it, I downloaded a new copy of the XAMPP server software, install it without making any modification, moved some files within is 'htdocs' (ie: 'E:\xampp\htdocs\')(the directories and files needed by the PHP script) and run the script. The same error 'Could not find/open font...' was displayed!  :evil:

I even tried to go back in time, I extracted XAMPP/PHP version 5.6.8 ... but could not get the server started...  :evil:

After searching the Web for an additional two hours and trying different proposed suggestions, I have FINALLY found a solution to the 'imagettfbbox' function 'Could not find/open font...' error!!  :mrgreen:

Although the solution is simple, it was not that obvious: When using True Type Fonts with functions such as 'imagettftext or imagettfbbox' the 'canonicalized absolute pathname' must be use, the path to the font thus must be enclosed into the 'realpath()' function, such as, for an arial True Type font found in the 'font' root directory:

Code: [Select]
$TTFfile = realpath( ''../../fonts/arial.ttf'' );
OK, hopefully, this is the end of the 'Could not find/open font...' error...  :roll:

Any way, I have been seriously thinking of stopping any Web development... As I have 'invested' in a WeatherFlow Smart Weather Station, I am now using a specific app (on both my tablet and my 'supposedly intelligent' phone) to get and display the data from my station. Obviously, I have also been spending a lot of time within the WeatherFlow Community/forums.

And there is this other venture where I am also spending a lot of time (more time than I have been spending within the weather-related forums): Home automation using all those neat IoT devices...  \:D/
R_o_B
---
eMail: weather@herray.net

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Dual-Image Problem
« Reply #11 on: November 29, 2018, 07:20:30 PM »
Glad you found the root cause for the issue.. good sleuthing, Ray.   =D>
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: Dual-Image Problem
« Reply #12 on: November 29, 2018, 07:31:08 PM »
Well, I was just getting at the end of my patience...  :evil:

Had I not eventually found a solution, I would probably have shut down the server software on my development computer (due to a lack of interest) and explore other interesting (and less aggravating) venture...  ;)
R_o_B
---
eMail: weather@herray.net

 

anything