1.3.6 Help with Dynamically Generated Images

Forum
Last Post
Threads / Messages
Could you try right clicking the broken image and opening it in a new tab? It might give an error that could lead us in the right direction :LOL:
This page isn’t workingemotidogs.online is currently unable to handle this request.
HTTP ERROR 500
 
This page isn’t workingemotidogs.online is currently unable to handle this request.
HTTP ERROR 500
That sounds like an issue with your host unfortunately, I don't think the code we've been doing should cause something like that. The error is just a generic one so nothing specific to help with troubleshooting
 
That sounds like an issue with your host unfortunately, I don't think the code we've been doing should cause something like that. The error is just a generic one so nothing specific to help with troubleshooting
Weird, because x10hosting is doing it too. My original host is godaddy. What host do you use?
 
Weird, because x10hosting is doing it too. My original host is godaddy. What host do you use?
I don't currently have a host, I'm using a program called WAMP just to develop locally on my PC. It doesn't come with Imagick by default so I had to install it myself which was a huge pain lmao. I do have a version with mysidiahosting where I was testing it on a live server that does work but I don't think they offer custom domains just yet. You'd need to message Hall of Famer on here for questions to do with myshosting as they run it.

If it is the code doing it I could go through it again and see. Could you resend me the files you've been using? And a screenshot of your DB? Hopefully we can get to the bottom of it lol :ROFLMAO:
 
I don't currently have a host, I'm using a program called WAMP just to develop locally on my PC. It doesn't come with Imagick by default so I had to install it myself which was a huge pain lmao. I do have a version with mysidiahosting where I was testing it on a live server that does work but I don't think they offer custom domains just yet. You'd need to message Hall of Famer on here for questions to do with myshosting as they run it.

If it is the code doing it I could go through it again and see. Could you resend me the files you've been using? And a screenshot of your DB? Hopefully we can get to the bottom of it lol :ROFLMAO:
Ah, I'll see if I can try mysidia hosting if I can sign up for it. Here is a link to my files. Agreed, lol. Thanks for helping me with this goose chase xD

Screenshot (53).png
 
I don't currently have a host, I'm using a program called WAMP just to develop locally on my PC. It doesn't come with Imagick by default so I had to install it myself which was a huge pain lmao. I do have a version with mysidiahosting where I was testing it on a live server that does work but I don't think they offer custom domains just yet. You'd need to message Hall of Famer on here for questions to do with myshosting as they run it.

If it is the code doing it I could go through it again and see. Could you resend me the files you've been using? And a screenshot of your DB? Hopefully we can get to the bottom of it lol :ROFLMAO:
Ok so I got myself a new site on mysidia hosting (https://pixellatopia.mysidiahost.com/). I've abandoned my previous idea for one that is way more unique and if it works will be insane. Not going to spoil the concept here but let's just say that my idea will require a whopping 25 markings to code in... yay me. It will be so worth it if I can get it working though. I'll start working on it today and hopefully there won't be any errors!

Spoke too soon...

Warning: Undefined variable $adopt in /home/pixellat/public_html/model/domainmodel/ownedadoptable.php on line 132

Warning
: Attempt to read property "aid" on null in /home/pixellat/public_html/model/domainmodel/ownedadoptable.php on line 132

Fatal error
: Uncaught TypeError: Resource\Core\AppController::setField(): Argument #2 ($value) must be of type ?Resource\Native\Objective, string given, called in /home/pixellat/public_html/controller/main/myadoptscontroller.php on line 47 and defined in /home/pixellat/public_html/resource/core/appcontroller.php:183 Stack trace: #0 /home/pixellat/public_html/controller/main/myadoptscontroller.php(47): Resource\Core\AppController->setField('image', '/adoptimage/vie...') #1 [internal function]: Controller\Main\MyadoptsController->manage('1') #2 /home/pixellat/public_html/resource/core/frontcontroller.php(196): ReflectionMethod->invokeArgs(Object(Controller\Main\MyadoptsController), Array) #3 /home/pixellat/public_html/controller/main/indexcontroller.php(13): Resource\Core\FrontController->triggerAction() #4 /home/pixellat/public_html/resource/core/frontcontroller.php(142): Controller\Main\IndexController->triggerAction() #5 /home/pixellat/public_html/index.php(75): Resource\Core\FrontController->handleRequest() #6 /home/pixellat/public_html/index.php(84): IndexController->run() #7 /home/pixellat/public_html/index.php(88): IndexController::main() #8 {main} thrown in /home/pixellat/public_html/resource/core/appcontroller.php on line 183
 

Attachments

  • adoptimagecontroller.php
    20.5 KB · Views: 0
  • adoptimageview.php
    637 bytes · Views: 0
  • myadoptsview.php
    10.7 KB · Views: 0
  • ownedadoptable.php
    9.5 KB · Views: 0
  • ownedadoptableviewmodel.php
    2 KB · Views: 0
Last edited:
Ok so I got myself a new site on mysidia hosting (https://pixellatopia.mysidiahost.com/). I've abandoned my previous idea for one that is way more unique and if it works will be insane. Not going to spoil the concept here but let's just say that my idea will require a whopping 25 markings to code in... yay me. It will be so worth it if I can get it working though. I'll start working on it today and hopefully there won't be any errors!

Spoke too soon...

Warning: Undefined variable $adopt in /home/pixellat/public_html/model/domainmodel/ownedadoptable.php on line 132

Warning
: Attempt to read property "aid" on null in /home/pixellat/public_html/model/domainmodel/ownedadoptable.php on line 132

Fatal error
: Uncaught TypeError: Resource\Core\AppController::setField(): Argument #2 ($value) must be of type ?Resource\Native\Objective, string given, called in /home/pixellat/public_html/controller/main/myadoptscontroller.php on line 47 and defined in /home/pixellat/public_html/resource/core/appcontroller.php:183 Stack trace: #0 /home/pixellat/public_html/controller/main/myadoptscontroller.php(47): Resource\Core\AppController->setField('image', '/adoptimage/vie...') #1 [internal function]: Controller\Main\MyadoptsController->manage('1') #2 /home/pixellat/public_html/resource/core/frontcontroller.php(196): ReflectionMethod->invokeArgs(Object(Controller\Main\MyadoptsController), Array) #3 /home/pixellat/public_html/controller/main/indexcontroller.php(13): Resource\Core\FrontController->triggerAction() #4 /home/pixellat/public_html/resource/core/frontcontroller.php(142): Controller\Main\IndexController->triggerAction() #5 /home/pixellat/public_html/index.php(75): Resource\Core\FrontController->handleRequest() #6 /home/pixellat/public_html/index.php(84): IndexController->run() #7 /home/pixellat/public_html/index.php(88): IndexController::main() #8 {main} thrown in /home/pixellat/public_html/resource/core/appcontroller.php on line 183
It looks like something is causing the Objective object to be preemptively converted into a string. Could you put the following code in model/domainmodel/ownedadoptable.php at the beginning of the getImage() function (so right after line 200), and share the output please? This will help us narrow down what the function's doing before it errors out.

PHP:
        var_dump([
            'fetchMode' => $fetchMode,
            'currentLevel' => $this->currentlevel,
            'imageurl' => $this->imageurl,
            'alternate' => $this->alternate,
            'getImageUrl' => $this->getImageURL($fetchMode),
            'getPrimaryImage' => $this->getCurrentLevel('model')->getPrimaryImage($fetchMode),
            'getImage' => $this->getAlternate('model')->getImage($fetchMode),
        ]);
 
It looks like something is causing the Objective object to be preemptively converted into a string. Could you put the following code in model/domainmodel/ownedadoptable.php at the beginning of the getImage() function (so right after line 200), and share the output please? This will help us narrow down what the function's doing before it errors out.

PHP:
        var_dump([
            'fetchMode' => $fetchMode,
            'currentLevel' => $this->currentlevel,
            'imageurl' => $this->imageurl,
            'alternate' => $this->alternate,
            'getImageUrl' => $this->getImageURL($fetchMode),
            'getPrimaryImage' => $this->getCurrentLevel('model')->getPrimaryImage($fetchMode),
            'getImage' => $this->getAlternate('model')->getImage($fetchMode),
        ]);
Tysm! Idk if I'm putting that code in the wrong place, but I can't get it to do anything.
 

Attachments

  • ownedadoptable (1).php
    9.5 KB · Views: 1
Tysm! Idk if I'm putting that code in the wrong place, but I can't get it to do anything.
I'm not seeing the call to var_dump in the file you attached - did you perhaps attach the other version of the file?

edit: Actually, I think I see what's going on here. Assuming that the attached file is the version you're running on your site, I'm thinking that the fact that you're returning a string is what's causing that error to be raised (as opposed to something causing the Objective instance to be cast to a string).

Since the function that calls getImage() expects an instance of Objective, let's try doing this:

PHP:
public function getImage($fetchMode = "") {
        $home =  SCRIPTPATH . '/';
        if ($this->getLastUpdate() !== $this->getImgLastUpdate()) {
            return new Image("{$home}adoptimage/view/{$this->getAdoptID()}");
        } else {
            return new Image("{$home}picuploads/adopt_images/{$this->getAdoptID()}.png?{$this->getImgLastUpdate()}");
        }
}
 
Last edited:
I'm not seeing the call to var_dump in the file you attached - did you perhaps attach the other version of the file?

edit: Actually, I think I see what's going on here. Assuming that the attached file is the version you're running on your site, I'm thinking that the fact that you're returning a string is what's causing that error to be raised (as opposed to something causing the Objective instance to be cast to a string).

Since the function that calls getImage() expects an instance of Objective, let's try doing this:

PHP:
public function getImage($fetchMode = "") {
        $home =  SCRIPTPATH . '/';
        if ($this->getLastUpdate() !== $this->getImgLastUpdate()) {
            return new Image("{$home}adoptimage/view/{$this->getAdoptID()}");
        } else {
            return new Image("{$home}picuploads/adopt_images/{$this->getAdoptID()}.png?{$this->getImgLastUpdate()}");
        }
}
That worked, although the image still isn't working. Trying to see if it has something to do with the database...? When I open the image in a new tab it just opens the index page. Here are my files.
 

Attachments

  • Screenshot (40).png
    Screenshot (40).png
    108.3 KB · Views: 2
  • ownedadoptableviewmodel (1).php
    2 KB · Views: 0
  • ownedadoptable (2).php
    9.5 KB · Views: 0
  • adoptimageview (1).php
    637 bytes · Views: 0
  • myadoptsview (1).php
    10.7 KB · Views: 1
  • adoptimagecontroller (1).php
    20.5 KB · Views: 1
That worked, although the image still isn't working. Trying to see if it has something to do with the database...? When I open the image in a new tab it just opens the index page. Here are my files.
Could you put this after line 49 in view/main/myadoptsview.php and let me know what you see? Or if you can let me know when it's up, I can go to the page and view it as well with my test account.

PHP:
$document->add(new Comment("<br><br>" . var_export($this->getField('image'), true) ."<br>"));

The above line should be placed right after $document->add($image) in case your file has any modifications and line 49 for you is something different.
 
Could you put this after line 49 in view/main/myadoptsview.php and let me know what you see? Or if you can let me know when it's up, I can go to the page and view it as well with my test account.

PHP:
$document->add(new Comment("<br><br>" . var_export($this->getField('image'), true) ."<br>"));

The above line should be placed right after $document->add($image) in case your file has any modifications and line 49 for you is something different.
Resource\GUI\Component\Image::__set_state(array( 'alt' => NULL, 'src' => Resource\Utility\URL::__set_state(array( 'scheme' => NULL, 'host' => NULL, 'path' => NULL, 'query' => NULL, 'fragment' => NULL, 'url' => 'https://pixellatopia.mysidiahost.com//picuploads/adopt_images/1.png?0', )), 'width' => NULL, 'height' => NULL, 'action' => NULL, 'type' => NULL, 'containers' => array ( ), 'name' => NULL, 'visible' => true, 'align' => NULL, 'font' => NULL, 'foreground' => NULL, 'background' => NULL, 'css' => NULL, 'container' => NULL, 'lineBreak' => false, 'id' => NULL, 'class' => NULL, 'event' => NULL, 'attributes' => ArrayObject::__set_state(array( 'Src' => true, )), 'renderer' => Resource\GUI\Renderer\AccessoryRenderer::__set_state(array( 'tag' => 'img', 'component' => NULL, 'render' => '', 'status' => 'ready', )), ))

When image is opened in new tab I get the error in the screenshot
 

Attachments

  • Screenshot (41).png
    Screenshot (41).png
    74.4 KB · Views: 2
Resource\GUI\Component\Image::__set_state(array( 'alt' => NULL, 'src' => Resource\Utility\URL::__set_state(array( 'scheme' => NULL, 'host' => NULL, 'path' => NULL, 'query' => NULL, 'fragment' => NULL, 'url' => 'https://pixellatopia.mysidiahost.com//picuploads/adopt_images/1.png?0', )), 'width' => NULL, 'height' => NULL, 'action' => NULL, 'type' => NULL, 'containers' => array ( ), 'name' => NULL, 'visible' => true, 'align' => NULL, 'font' => NULL, 'foreground' => NULL, 'background' => NULL, 'css' => NULL, 'container' => NULL, 'lineBreak' => false, 'id' => NULL, 'class' => NULL, 'event' => NULL, 'attributes' => ArrayObject::__set_state(array( 'Src' => true, )), 'renderer' => Resource\GUI\Renderer\AccessoryRenderer::__set_state(array( 'tag' => 'img', 'component' => NULL, 'render' => '', 'status' => 'ready', )), ))

When image is opened in new tab I get the error in the screenshot
One thing I notice off the bat is that there's a redundant slash in the file path, so I think we can update the following line in getImage():

PHP:
$home = SCRIPTPATH . '/';

To be $home = SCRIPTPATH;

(At some point we can get rid of this variable altogether now, but just for simplicity's sake while we're troubleshooting, so we only need to change one line, we'll do it like this...)

I'm not sure if this will fix the issue we're seeing on the adoptable manage page yet, because I noticed that instead of the expected image source, it's calling the object's __toString() method. So we'll start with seeing whether we can fix these things when we go to the URLs directly, and work our way from there.

Now, for the error concerning picuploadsController, my guess as to what's happening is that the file doesn't exist, so it's falling back to routing the request through index.php and thus we get the error complaining about the lack of a controller for this subdirectory.

It's expected that we don't have a picuploadsController since it looks like Apache handles all of the static assets, like images.

Can you confirm whether picuploads/adopt_images is a directory, and that the file named 1.png exists within it?

Secondly there's another error in the other path that I noticed:

Code:
unexpected variable "$composed_image" in /home/pixellat/public_html/controller/main/adoptimagecontroller.php on line 109

This specific error seems to be because you're missing semicolons in a few places. For example, at the end of line 107.

I've attached an updated version that adds all the missing semicolons. There may be other errors related to this one, but try replacing that file with the attached version and we can go from there.
 

Attachments

  • adoptimagecontroller (1).php
    20.6 KB · Views: 1
Update: I see why it's calling __toString() now - I didn't notice before that your version of myadoptsview.php was different, but after going back and looking at the attachments again, I noticed it listed there.

At line 49 you have the following:

PHP:
$adoptImage = new Image("{$ownedAdopt->getImage()}");

This can be simplified to the following since getImage() will now return an instance of Image:

PHP:
$adoptImage = $ownedAdopt->getImage();

In the first way, the Image instance is being cast to a string by PHP, because the Image class implements a method named __toString(), and the object is interpolated into a string due to being surrounded by double quotes. This conversion is why we see a broken image with the following source in devtools:

Screenshot 2023-12-27 at 7.27.40 PM.png

Following the change in the second way however, once we resolve any outstanding errors for the image URLs, we should be able to view the image on the manage page.
 
One thing I notice off the bat is that there's a redundant slash in the file path, so I think we can update the following line in getImage():

PHP:
$home = SCRIPTPATH . '/';

To be $home = SCRIPTPATH;

(At some point we can get rid of this variable altogether now, but just for simplicity's sake while we're troubleshooting, so we only need to change one line, we'll do it like this...)

I'm not sure if this will fix the issue we're seeing on the adoptable manage page yet, because I noticed that instead of the expected image source, it's calling the object's __toString() method. So we'll start with seeing whether we can fix these things when we go to the URLs directly, and work our way from there.

Now, for the error concerning picuploadsController, my guess as to what's happening is that the file doesn't exist, so it's falling back to routing the request through index.php and thus we get the error complaining about the lack of a controller for this subdirectory.

It's expected that we don't have a picuploadsController since it looks like Apache handles all of the static assets, like images.

Can you confirm whether picuploads/adopt_images is a directory, and that the file named 1.png exists within it?

Secondly there's another error in the other path that I noticed:

Code:
unexpected variable "$composed_image" in /home/pixellat/public_html/controller/main/adoptimagecontroller.php on line 109

This specific error seems to be because you're missing semicolons in a few places. For example, at the end of line 107.

I've attached an updated version that adds all the missing semicolons. There may be other errors related to this one, but try replacing that file with the attached version and we can go from there.
Changed the myadoptsview.php, but I'm a bit confused on what file I need to change the $home = SCRIPTPATH . '/';

Also added the updated file.

The markings are labelled as marking1, marking2, etc because I noticed that it was calling the marking1 image for the testing adopt otherwise. It is strange that imagemagick doesn't seem to be running, though.
 
Changed the myadoptsview.php, but I'm a bit confused on what file I need to change the $home = SCRIPTPATH . '/';

Also added the updated file.

The markings are labelled as marking1, marking2, etc because I noticed that it was calling the marking1 image for the testing adopt otherwise. It is strange that imagemagick doesn't seem to be running, though.
That change for $home will be in model/domainmodel/ownedadoptable.php, specifically in the getImage() function. Ctrl + F for function getImage and then find the line that looks like $home = SCRIPTPATH . '/';, and replace it with the $home = SCRIPTPATH; version, and you're good to go there.

The names of the markings should be fine as far as I'm aware, but yeah, it is odd that Imagemagick isn't doing anything. Can you create a file in the directory you uploaded Mysidia into named phpinfo.php with the following code, and let me know when it's up? I want to take a look at your server's PHP config to see if anything stands out re: the Imagemagick extension.

PHP:
<?php phpinfo(); ?>

edit: Looking at adoptimage/view I think we're making progress since now we have the actual page rendering. Judging from the error message, I'm wondering if the above change to the $home variable won't fix the "Failed to read the file" problem. Assuming that it's using the path that has two slashes (i.e. the one we're about to fix) then I think it's possible.

That reminds me - did you see this question in my last post?

Can you confirm whether picuploads/adopt_images is a directory, and that the file named 1.png exists within it?

You should be able to confirm this by opening your FTP client, or your host's file manager if using something like CPanel, and navigating to the picuploads directory - then if you want you could reply with an attached screenshot, showing what files and folders exist in that directory, to help me narrow down the issue with the picuploads/adopt_images URLs.
 
Last edited:
That change for $home will be in model/domainmodel/ownedadoptable.php, specifically in the getImage() function. Ctrl + F for function getImage and then find the line that looks like $home = SCRIPTPATH . '/';, and replace it with the $home = SCRIPTPATH; version, and you're good to go there.

The names of the markings should be fine as far as I'm aware, but yeah, it is odd that Imagemagick isn't doing anything. Can you create a file in the directory you uploaded Mysidia into named phpinfo.php with the following code, and let me know when it's up? I want to take a look at your server's PHP config to see if anything stands out re: the Imagemagick extension.

PHP:
<?php phpinfo(); ?>

edit: Looking at adoptimage/view I think we're making progress since now we have the actual page rendering. Judging from the error message, I'm wondering if the above change to the $home variable won't fix the "Failed to read the file" problem. Assuming that it's using the path that has two slashes (i.e. the one we're about to fix) then I think it's possible.

That reminds me - did you see this question in my last post?



You should be able to confirm this by opening your FTP client, or your host's file manager if using something like CPanel, and navigating to the picuploads directory - then if you want you could reply with an attached screenshot, showing what files and folders exist in that directory, to help me narrow down the issue with the picuploads/adopt_images URLs.
Fixed the scriptpath error, but now the image isn't loading at all and is throwing this again: Fatal Error: Class Controller\Main\picuploadsController either does not exist, or has its include path misconfigured!

Also added the phpinfo file.

Attached are the screenshots of adopt_images

edit: maybe the code is throwing the error because it's expecting imagemagick to render 1.png as a file and save it to adopt_images?
 

Attachments

  • Screenshot (44).png
    Screenshot (44).png
    170.3 KB · Views: 1
  • Screenshot (45).png
    Screenshot (45).png
    170.7 KB · Views: 1
Fixed the scriptpath error, but now the image isn't loading at all and is throwing this again: Fatal Error: Class Controller\Main\picuploadsController either does not exist, or has its include path misconfigured!

Also added the phpinfo file.

Attached are the screenshots of adopt_images

edit: maybe the code is throwing the error because it's expecting imagemagick to render 1.png as a file and save it to adopt_images?
Yeah, I think that's basically what's happening. My guess is that it goes something like this: Apache gets the request for picuploads/adopt_images/1.png and looks for the image file at that path. The file doesn't exist, so Apache goes on to the next request handler specified in the htaccess file, which sends the request to index.php. Mysidia then attempts to find a controller from the URL and can't, so it throws the error.

To test this, let's try something: Pick any random PNG and name it 1.png. Upload it to picuploads/adopt_images and let's see if the file loads without that error.

If it does, then we can attempt to narrow down why the file wasn't created. It's possible that it was due to the filepath misconfiguration from before, in which case, maybe we test a new adoption to see if that creates 3.png. (Assuming that's what triggers the image rendering process - correct me if I'm mistaken about that.)

I'll take a look at the PHP info in the meantime and see if anything stands out re: the extension.
 
Yeah, I think that's basically what's happening. My guess is that it goes something like this: Apache gets the request for picuploads/adopt_images/1.png and looks for the image file at that path. The file doesn't exist, so Apache goes on to the next request handler specified in the htaccess file, which sends the request to index.php. Mysidia then attempts to find a controller from the URL and can't, so it throws the error.

To test this, let's try something: Pick any random PNG and name it 1.png. Upload it to picuploads/adopt_images and let's see if the file loads without that error.

If it does, then we can attempt to narrow down why the file wasn't created. It's possible that it was due to the filepath misconfiguration from before, in which case, maybe we test a new adoption to see if that creates 3.png. (Assuming that's what triggers the image rendering process - correct me if I'm mistaken about that.)

I'll take a look at the PHP info in the meantime and see if anything stands out re: the extension.
Yeah it still throws the error even with an image loading. I just remembered I forgot to implement it saving as an image (I think it's on like page one or two) so I can try getting that up and see if it does anything.
 

Attachments

  • Screenshot (47).png
    Screenshot (47).png
    291.5 KB · Views: 1

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top