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

0 Members and 1 Guest are viewing this topic.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #25 on: December 11, 2024, 05:12:36 PM »
You should likely sleep now. I'll continue some research today.

I'm sure the issue is with the GD 2.3.3 on your host.. on GD 2.1.0 compatible it is working.  I'll need to find a 2.3.3 GD to test with locally.
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 #26 on: December 11, 2024, 05:15:41 PM »
Thank you Ken, always grateful for your work and dedication, surprised by your desire to solve the problem.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #27 on: December 11, 2024, 05:54:01 PM »
One more tweak to try .. download from sunposa.php

It trys to reset pixels in the sun image to the background transparent color.
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 #28 on: December 11, 2024, 05:57:56 PM »
 :sad:

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9697
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Sunposa background black sun
« Reply #29 on: December 11, 2024, 06:05:06 PM »
Grrrr... I'll have to locate/create a PHP with GD 2.3.3 to do local debugging.

Despite having the residual square outline (which should transparent), your instance is stubbornly refusing to behave as expected.

At least, the sun image is round with the solar prominences clipped off, and that was a desired outcome.

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 Vasco

  • Forecaster
  • *****
  • Posts: 634
    • PWS
Re: Sunposa background black sun
« Reply #30 on: December 11, 2024, 06:10:59 PM »
Grrrr... I'll have to locate/create a PHP with GD 2.3.3 to do local debugging.

I was using 2.2.5 (on SunOS) when I had a similar problem back in August. . . but 2.3.3 (on Linux) worked.
« Last Edit: December 20, 2024, 05:55:12 AM by Vasco »
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline Weatherstation De Hout

  • Member
  • *
  • Posts: 11
    • Weatherstation De Hout Alkmaar
Re: Sunposa background black sun
« Reply #31 on: December 12, 2024, 03:57:10 PM »
@Ken: check this. It looks like the same problem, with possibly a fix given in the third-to-last post?
https://github.com/spatie/laravel-medialibrary/issues/3502
CU1 | Weather Station Website: https://www.alkmaarweer.nl | Davis Vantage Pro2+ FARS

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #32 on: December 14, 2024, 05:26:12 PM »
Hello, installed version 3.70 from 14.12.24 and it has a similar problem
« Last Edit: December 14, 2024, 05:30:03 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 #33 on: December 14, 2024, 05:48:08 PM »
Yes, your PHP 8.4.1 using GD Version: 2.3.3 is the issue.  I know that @vasco uses GD 2.3.3 successfully on his SunOS hosting, but the vast majority of users have PHP versions with  GD Version: bundled (2.1.0 compatible) and that works just fine.

I tried PHP 8.4.0 on a WAMP server, but it had  GD Version: bundled (2.1.0 compatible) and so worked just fine.

I am afraid you'll have to live with the pink surround of the sun given your current webserver setup.  It just doesn't support transparency as expected.  Sorry.
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 #34 on: December 14, 2024, 06:24:53 PM »
Thanks Ken!!

Offline Vasco

  • Forecaster
  • *****
  • Posts: 634
    • PWS
Re: Sunposa background black sun
« Reply #35 on: December 20, 2024, 05:54:36 AM »
Just got round to checking out sunposa version 3.70 and it works fine with GD 2.3.3 in PHP 8.2.26 on Linux host.

Much better sun image: https://swanston.maui.co.uk/ajax/wxastronomy.php
« Last Edit: December 20, 2024, 05:57:29 AM by Vasco »
Ecowitt GW1102 (with GW2000) + Weather Display in Windows 10

Offline CarlosLSev

  • Senior Member
  • **
  • Posts: 62
Re: Sunposa background black sun
« Reply #36 on: December 21, 2024, 06:37:10 AM »
Hi Ken, I modified the function and it now works for me in php 8.4.1




Code: [Select]
// Turn black background transparent fix php 8.4.1
 function maketransparent($oldfile, $newfile, $width, $height)
{
    global $myProxy, $cacheFileDir;
    $tfileName = $cacheFileDir . 'tempImg.gif';
    $tfile = get_file_contents($oldfile);
    if (!$tfile) {
        header('Content-type: text/plain;charset=ISO-8859-1');
        print "..Oops .. unable to fetch '$oldfile' .. exiting.";
        exit(0);
    }
    file_put_contents($tfileName, $tfile);
    $info = getimagesize($tfileName);
    if (!is_array($info)) {
        if (!headers_sent()) {
            header('Content-type: text/plain');
        }
        print "-- error fetching image size from $oldfile.  Unable to continue.\n";
        exit(1);
    }
    $im = imagecreatefromgif($tfileName);
    if ($im == false) {
        if (!headers_sent()) {
            header('Content-type: text/plain');
        }
        print "-- error fetching image file $oldfile for processing.  Unable to continue.\n";
        exit(1);
    }

    $img = imagecreatetruecolor($width, $height);
    $img2 = imagecreatetruecolor($info[0], $info[1]);
    imagealphablending($img2, false);
    imagesavealpha($img2, true);
    imagecopy($img2, $im, 0, 0, 0, 0, $info[0], $info[1]);
    imageRemoveOuterCircle($img2, $info[0], $info[1], 20);
    $trans = imagecolorat($img2, 0, 0);
    imagecolortransparent($img2, $trans);
    imagealphablending($img, false);
    imagesavealpha($img, true);
    imagecopyresampled($img, $img2, 0, 0, 0, 0, $width, $height, $info[0], $info[1]);

    $trans2 = imagecolorallocatealpha($img, 0, 0, 0, 127);
    imagefill($img, 0, 0, $trans2);
    imagecolortransparent($img, $trans2);

    $wt2 = imagesx($img);
    $ht2 = imagesy($img);
    for ($xt = 0; $xt < $wt2; $xt++) {
        for ($yt = 0; $yt < $ht2; $yt++) {
            $pixel = imagecolorsforindex($img, imagecolorat($img, $xt, $yt));
            if ($pixel['alpha'] >= 64) {
                imagesetpixel($img, $xt, $yt, $trans2);
            }
        }
    }

    imagegif($img, $newfile);
    imagedestroy($img);
}



Offline meteosanjuan

  • Contributor
  • ***
  • Posts: 123
    • Meteoensevilla
Re: Sunposa background black sun
« Reply #37 on: December 21, 2024, 06:44:37 AM »
Hi Ken, I modified the function and it now works for me in php 8.4.1





How great my friend Carlos  [tup]

 

anything