Author Topic: Sunposa background black sun  (Read 5322 times)

0 Members and 1 Guest are viewing this topic.

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Sunposa background black sun
« on: December 03, 2024, 10:03:34 AM »
Hello, my sunposa.php file looks like this. With a black background in the image of the sun, if I upload jpsun.png to ./cache it is solved but when it is generated again it comes out wrong again. Suggestions?
 [ You are not allowed to view attachments ]

Offline Vasco

  • Forecaster
  • *****
  • Posts: 647
    • PWS
Re: Sunposa background black sun
« Reply #1 on: December 03, 2024, 10:56:06 AM »
I had this with a GD function problem: running .../sunposa.php?debug=y shows that the GD library is available.

Think you might have to wait for Ken to see this  :?
« Last Edit: December 03, 2024, 10:58:52 AM by Vasco »
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #2 on: December 03, 2024, 10:58:08 AM »
------------------------------------------------------------------
sunposa.php Version 3.60 - 11-Sep-2024
..debug=y debugging output for sunposa.php.  PHP version 7.4.33

  Status of needed built-in PHP functions:
  function 'imagecreatefrompng()'  is available
  function 'imagecreatefromgif()'  is available
  function 'imagecreatetruecolor()'  is available
  function 'imagecolortransparent()'  is available
  function 'imagettfbbox()'  is available
  function 'imagettftext()'  is available
  function 'gregoriantojd()'  is available
  function 'curl_init()'  is available
  function 'curl_setopt()'  is available
  function 'curl_exec()'  is available
  function 'curl_error()'  is available
  function 'curl_getinfo()'  is available
  function 'curl_close()'  is available

  Settings used:
  lat='37.396306', lon='-5.718556', tz='Europe/Madrid'
  cacheFileDir='./cache/'
  moonImagePath='./moonimg/NH-moon'
  legendColor='orange' maxElevation='90'
  jpgraph location='./jpgraph-4.4.2-src-only/'
  Using internal calculations for moon data.
  moon image cache './cache/jpmoon.png exists. Updated 2024-12-03 05:39:16
  sun  image NASA  './cache/tempImg.gif exists.  Updated 2024-12-03 15:33:01
  sun  image cache './cache/jpsun.png exists.  Updated 2024-12-03 15:33:01

  GD Library is available and has these capabilities:
    GD Version: 2.3.3
    FreeType Support: true
    FreeType Linkage: false
    GIF Read Support: true
    GIF Create Support: true
    JPEG Support: true
    PNG Support: true
    WBMP Support: true
    XPM Support: true
    XBM Support: true
    WebP Support: true
    BMP Support: true
    TGA Read Support: true
    JIS-mapped Japanese Font Support: false

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #3 on: December 03, 2024, 11:27:32 AM »
Hello according to the script
FreeType Link: false
Next phpinfo FreeType support enabled
FreeType link with free type
Hello this
sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt install --reinstall php7.4-gd
systemctl restarts apache2
I'm not sure if freetype is the problem

Offline Vasco

  • Forecaster
  • *****
  • Posts: 647
    • PWS
Re: Sunposa background black sun
« Reply #4 on: December 03, 2024, 11:42:37 AM »
I don't think so... Mine was a problem with one particular GD function, see https://www.wxforum.net/index.php?topic=47370.msg477393#msg477393

Hope that Ken can sort you out  ;)
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #5 on: December 03, 2024, 01:04:19 PM »
Hello, how do I use php 7.4.33? I have modified the jpgraph.php file and I left it before the modification that Ken made (it can be seen that he left it corrected in the version that he uploaded) for php 8+ I am going to try it tomorrow and if not I will leave it as was

The same correction for php 8 does not work well for php 7, although I doubt it.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #6 on: December 03, 2024, 02:43:17 PM »
It is a problem with the imagecolortransparent() GD function not behaving normally with your GD installation.  It is likely that is the problem with GD Version: 2.3.3 on PHP 7.4.33.

A function within sunposa.php uses that GD function to create a mask around the sun image from NASA which has a black background to change the image outside a circle into transparent for the PNG image.

I'd suggest that you update to PHP 8+ to fix the issue.
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 CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #7 on: December 04, 2024, 05:36:54 AM »
After updating to 8.1 it already seems to work, thanks Ken

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #8 on: December 04, 2024, 07:12:44 AM »
Hello, it has been working but the black background has appeared again, also the moon does not correspond, I am going to investigate

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #9 on: December 05, 2024, 12:17:53 PM »
Today I decided to update PHP to 8.4.1, and I have re-uploaded the complete sunposa script, the result is the same :( black background behind the sun and moon does not correspond even though the latitude and longitude and time zone are correctly configured

https://www.meteoviso.es/wxastronomy.php



Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #10 on: December 05, 2024, 12:25:28 PM »
Try changing Settings.php from
Quote
$SITE['latitude']      = '37.396306';    //North=positive, South=negative decimal degrees
$SITE['longitude']      = '-5.718556';  //East=positive, West=negative decimal degrees
to
Quote
$SITE['latitude']      = 37.396306;    //North=positive, South=negative decimal degrees
$SITE['longitude']      = -5.718556;  //East=positive, West=negative decimal degrees

also when running sunposa.php?force=1 to reload the cache it has the following error:
Quote
<b>Warning</b>:  imagepng(./cache/jpmoon.png): Failed to open stream: Permission denied in <b>/var/www/html/sunposa.php</b> on line <b>976</b><br />
so check permissions on your cache/ directory to allow files to be written.
« Last Edit: December 05, 2024, 12:36:20 PM by saratogaWX »
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 CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #11 on: December 05, 2024, 12:58:02 PM »
Hello, I removed the single quotes and it seems to behave the same, I also removed some decimals to test.
I have to be very clumsy. I even uploaded the full script from https://github.com/ktrue/SunMoon-graph

PD
Ok, thanks Ken the moon now seems to be showing well, let's wait for the sun tomorrow
« Last Edit: December 05, 2024, 01:00:27 PM by CarlosLSev »

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #12 on: December 06, 2024, 05:46:58 AM »

The sun continues with the black background.

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #13 on: December 08, 2024, 02:54:23 PM »
 :shock: help me!!

Offline zeppline

  • Senior Member
  • **
  • Posts: 92
    • Las Vegas Weather Guy
Re: Sunposa background black sun
« Reply #14 on: December 09, 2024, 11:30:24 AM »
look in include-wxastronomy file a line 86 thru 102 you can change sun image. I have $sunC128, try different images.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #15 on: December 09, 2024, 08:22:37 PM »
:shock: help me!!
I'm working on an update that will use a different method to mask the sun image and have a transparent background.
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 saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #16 on: December 11, 2024, 02:19:23 PM »
Ok.. got a new version to test.  It seems the issue was with making the jpsun.png image keep transparency.
I've switched to using a function to vignette the sun image and save as jpsun.gif and that seems to work.

Please try V3.70 sunposa.php from https://saratoga-weather.org/sunposa.php?sce=view
and let me know if that works.
Note: you'll need permissions on the cache directory to allow creation of jpsun.gif the first time it is run.
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 CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #17 on: December 11, 2024, 02:31:11 PM »
Now it looks like this, it still has something behind it
 [ You are not allowed to view attachments ]
« Last Edit: December 11, 2024, 03:21:12 PM by CarlosLSev »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #18 on: December 11, 2024, 03:56:36 PM »
Yes, that is supposed to be transparent, not shown.

Your actual image shows the transparent failure.
Your GD library is GD Version: 2.3.3 with  PHP version 8.4.1
Mine is GD Version: bundled (2.1.0 compatible) on saratoga-weather.org with PHP version 8.1.31 and works fine
My actual image looks transparent.

My test (local system) uses GD Version: bundled (2.1.0 compatible) with PHP version 8.2.0 and it works fine too,

I'm suspecting that GD 2.3.3 may have a bug with handling transparency.  Try the download from
https://saratoga-weather.org/sunposa.php?sce=view and upload it again.  I tweaked the code a bit
to use imagecopyresized instead of imagecopyresampled for the sun + stuff to preserve alpha.

After upload, load https://www.meteoviso.es/sunposa.php?force=1 to reload the Sun image with the updated code.
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 saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #19 on: December 11, 2024, 04:08:06 PM »
Looks like your script is blowing up.. I suspect that the permissions on your ./cache/ directory disallow create of jpsun.gif

Download the image from the above post, upload to ./cache/jpsun.gif and the script should stop blowing up.
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 CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #20 on: December 11, 2024, 04:27:59 PM »
The files are created, if I delete them and execute force=1 it gives an error, but they are created again, if I execute debug=y it is executed and displayed on the screen but something prevents the script from displaying the image, cache has permissions 777

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #21 on: December 11, 2024, 04:57:19 PM »
Your sunposa.php has
Quote
""<?php

Remove the
Quote
""
before the <?php

But.. even after that change, your cache file doesn't have the expected transparent background:



while mine shows as



Sigh...
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 CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #22 on: December 11, 2024, 05:01:49 PM »
Sorry for the error, what you indicate still happens.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #23 on: December 11, 2024, 05:04:07 PM »
Ok, one more tweak to the code.. download sunposa.php and upload to your site.
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 CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #24 on: December 11, 2024, 05:10:15 PM »
Still the same, I'm embarrassed Ken that you take so much time on the script because of me. Although I will continue testing if necessary

 

anything