1.3.6 Help with Dynamically Generated Images

Forum
Last Post
Threads / Messages
If you want to go back to the default myadopts view with the table, instead of using the iterator to display pets, change public function index in myadoptsview.php to this:

PHP:
public function index(){
        $document = $this->document;
        $document->setTitle($this->lang->title);
 
        $pagination = $this->getField("pagination");
        $ownedAdopts = $this->getField("ownedAdopts");
       
        $adoptTable = new TableBuilder("adopttable", 650);
        $adoptTable->setAlign(new Align("center", "middle"));
        $adoptTable->buildHeaders("Gender", "Name/Type", "Image", "Level", "Clicks");
        $ownedAdoptsIterator = $ownedAdopts->iterator();
        while($ownedAdoptsIterator->hasNext()){
            $ownedAdopt = $ownedAdoptsIterator->next();
            $cells = new LinkedList;
            $cells->add(new TCell($ownedAdopt->getGenderImage()));
            $cells->add(new TCell($ownedAdopt->getTypeAndName()));
            $cells->add(new TCell($ownedAdopt->getManageLink()));
            $cells->add(new TCell($ownedAdopt->getCurrentLevel()));
            $cells->add(new TCell($ownedAdopt->getTotalClicks()));
            $adoptTable->buildRow($cells);
        }
        $document->add($adoptTable);
        $document->addLangvar($pagination->showPage());
    }

$ownedAdopt->getManageLink() is what displays the image, which we defined just now :3
I changed everything and am still getting an error on the manage adoptables page. I'm going insane.
 
Is there an error that shows up? Or is it just a blank page?

You can try copying this to myadoptsview, it's default:

PHP:
<?php

namespace View\Main;
use Resource\Collection\LinkedList;
use Resource\Core\Registry;
use Resource\Core\View;
use Resource\GUI\Component\Image;
use Resource\GUI\Component\Link;
use Resource\GUI\Component\TextArea;
use Resource\GUI\Container\TCell;
use Resource\GUI\Document\Comment;
use Resource\GUI\Element\Align;
use Service\Builder\FormBuilder;
use Service\Builder\TableBuilder;
use Service\Helper\UserTableHelper;

class MyadoptsView extends View{
    
    public function index(){
        $document = $this->document;
        $document->setTitle($this->lang->title);
 
        $pagination = $this->getField("pagination");
        $ownedAdopts = $this->getField("ownedAdopts");
        
        $adoptTable = new TableBuilder("adopttable", 650);
        $adoptTable->setAlign(new Align("center", "middle"));
        $adoptTable->buildHeaders("Gender", "Name/Type", "Image", "Level", "Clicks");
        $ownedAdoptsIterator = $ownedAdopts->iterator();
        while($ownedAdoptsIterator->hasNext()){
            $ownedAdopt = $ownedAdoptsIterator->next();
            $cells = new LinkedList;
            $cells->add(new TCell($ownedAdopt->getGenderImage()));
            $cells->add(new TCell($ownedAdopt->getTypeAndName()));
            $cells->add(new TCell($ownedAdopt->getManageLink()));
            $cells->add(new TCell($ownedAdopt->getCurrentLevel()));
            $cells->add(new TCell($ownedAdopt->getTotalClicks()));
            $adoptTable->buildRow($cells);
        }
        $document->add($adoptTable);
        $document->addLangvar($pagination->showPage());
    }
    
    public function manage(){       
        $document = $this->document;       
        $ownedAdopt = $this->getField("ownedAdopt");
        //$image = $this->getField("image");
        $document->setTitle("Managing {$ownedAdopt->getName()}");
        $adoptImage = new Image("{$ownedAdopt->getImage()}");
        $adoptImage->setWidth("300");
        $document->add($adoptImage);
        $document->add(new Comment("<br><br>This page allows you to manage {$ownedAdopt->getName()}.  Click on an option below to change settings.<br>"));
        
        $document->add(new Image("templates/icons/add.gif"));
        $document->add(new Link("levelup/click/{$ownedAdopt->getID()}", " Level Up {$ownedAdopt->getName()}", TRUE));
        $document->add(new Image("templates/icons/stats.gif"));
        $document->add(new Link("myadopts/stats/{$ownedAdopt->getID()}", " Get Stats for {$ownedAdopt->getName()}", TRUE));
        $document->add(new Image("templates/icons/bbcodes.gif"));
        $document->add(new Link("myadopts/bbcode/{$ownedAdopt->getID()}", " Get BBCodes / HTML Codes for {$ownedAdopt->getName()}", TRUE));
           $document->add(new Image("templates/icons/title.gif"));
        $document->add(new Link("myadopts/rename/{$ownedAdopt->getID()}", " Rename {$ownedAdopt->getName()}", TRUE));
        $document->add(new Image("templates/icons/trade.gif"));
        $document->add(new Link("myadopts/trade/{$ownedAdopt->getID()}", " Change Trade status for {$ownedAdopt->getName()}", TRUE));
        $document->add(new Image("templates/icons/freeze.gif"));
        $document->add(new Link("myadopts/freeze/{$ownedAdopt->getID()}", " Freeze or Unfreeze {$ownedAdopt->getName()}", TRUE));
        $document->add(new Image("templates/icons/delete.gif"));
        $document->add(new Link("pound/pound/{$ownedAdopt->getID()}", " Pound {$ownedAdopt->getName()}", TRUE));
    }
    
    public function stats(){
        $ownedAdopt = $this->getField("ownedAdopt");       
        $votes = $this->getField("votes");
        
        $document = $this->document;           
        $document->setTitle($ownedAdopt->getName() . $this->lang->stats);
        $document->add($ownedAdopt->getAdoptImage());   
        $document->add($ownedAdopt->getStats());           
        $document->addLangvar("<h2>{$ownedAdopt->getName()}'s Voters:</h2><br>{$this->lang->voters}<br><br>");   
        
        $helper = new UserTableHelper;
        $voterTable = new TableBuilder("voters", 500);
        $voterTable->setAlign(new Align("center"));
        $voterTable->buildHeaders("User", "Date Voted", "Profile", "PM");
        $voterTable->setHelper($helper);
        $votesIterator = $votes->iterator();
        while($votesIterator->hasNext()){
            $vote = $votesIterator->next();
            $cells = new LinkedList;
            $cells->add(new TCell($helper->getUsername($vote->getUsername())));
            $cells->add(new TCell($vote->getDate("Y-m-d")));
            $cells->add(new TCell($helper->getProfileImage($vote->getUserID())));
            $cells->add(new TCell($helper->getPMImage($vote->getUserID())));
            $voterTable->buildRow($cells);           
        }
        $document->add($voterTable);
    }
    
    public function bbcode(){
        $mysidia = Registry::get("mysidia");
        $adopt = $this->getField("adopt");           
        $document = $this->document;
        $document->setTitle($this->lang->bbcode . $adopt->getName());
        $document->addLangvar($this->lang->bbcode_info);
        $document->add(new Comment("<br>"));
        
        $forumComment = new Comment("Forum BBCode: ");       
        $forumComment->setUnderlined();
        $forumcode = "[url={$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}][img]{$mysidia->path->getAbsolute()}levelup/siggy/{$adopt->getAdoptID()}[/img][/url]";       
        $forumArea = new TextArea("forumcode", $forumcode, 4, 50);
        $forumArea->setReadOnly(TRUE);
        
        $altComment = new Comment("Alternative BBCode: ");       
        $altComment->setUnderlined();
        $altcode = "[url={$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}][img]{$mysidia->path->getAbsolute()}get/{$adopt->getAdoptID()}.gif\"[/img][/url]";
        $altArea = new TextArea("altcode", $altcode, 4, 50);
        $altArea->setReadOnly(TRUE);
        
        $htmlComment = new Comment("HTML BBCode: ");       
        $htmlComment->setUnderlined();
        $htmlcode = "<a href='{$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}' target='_blank'>
                     <img src='{$mysidia->path->getAbsolute()}levelup/siggy/{$adopt->getAdoptID()}' border=0></a>";
        $htmlArea = new TextArea("htmlcode", $htmlcode, 4, 50);
        $htmlArea->setReadOnly(TRUE);
        
        $document->add($forumComment);
        $document->add($forumArea);
        $document->add($altComment);
        $document->add(($mysidia->settings->usealtbbcode == "yes") ? $altArea : new Comment("The Admin has disabled Alt BBCode for this site."));
        $document->add($htmlComment);
        $document->add($htmlArea);
    }
    
    public function rename(){
        $mysidia = Registry::get("mysidia");
        $adopt = $this->getField("adopt");       
        $image = $this->getField("image");       
        $document = $this->document;
        
        if($mysidia->input->post("submit")){
            $document->setTitle($this->lang->rename_success_title);
            $document->add($image);
            $message = "<br>{$this->lang->rename_success}{$adopt->getName()}.
                        You can now manage {$adopt->getName()} on the";
            $document->addLangvar($message);
            $document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}", "My Adopts Page"));
            return;
        }
        
        $document->setTitle($this->lang->rename . $adopt->getName());
        $document->add($image);
        $document->addLangvar("<br />{$this->lang->rename_default}{$adopt->getName()}{$this->lang->rename_details}<br />");
        
        $renameForm = new FormBuilder("renameform", "", "post");
        $renameForm->buildTextField("adoptname")->buildButton("Rename Adopt", "submit", "submit");
        $document->add($renameForm);           
    }
    
    public function trade(){
        $adopt = $this->getField("adopt");
        $image = $this->getField("image");   
        $confirm = $this->getField("confirm");       
        $document = $this->document;
        $document->setTitle($this->lang->trade . $adopt->getName());
        $document->add($image);
        
        if($confirm) $document->addLangvar(($adopt->getTradeStatus() == "fortrade") ? $this->lang->trade_allow : $this->lang->trade_disallow);
        else{
            $document->addLangvar("Are you sure you wish to change the trade status of this adoptable?
                                   <center><b><a href='{$adopt->getAdoptID()}/confirm'>Yes I'd like to change its trade status</a></b><br /><br />
                                   <b><a href='../../myadopts'>Nope I change my mind! Go back to the previous page.</a></b></center><br />");
        }
    }
    
    public function freeze(){
        $adopt = $this->getField("adopt");       
        $image = $this->getField("image");   
        $confirm = $this->getField("confirm");
        $document = $this->document;       
        $document->setTitle($this->lang->freeze . $adopt->getName());   
        $document->add($image);
        
        if($confirm){
             $document->addLangvar(($adopt->isFrozen() == "yes") ? $this->lang->freeze_success : $this->lang->freeze_reverse);
             $document->addLangvar("<br>You may now manage {$adopt->getName()} on the ");
             $document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}", "My Adopts Page"));       
        }     
        else{
            $document->add(new Comment("<br /><b>{$adopt->getName()}'s Current Status: "));
            
            if($adopt->isfrozen() == "yes"){               
                $document->add(new Image("templates/icons/freeze.gif", "Frozen"));
                $document->add(new Comment("Frozen<br<br>"));
                $document->add(new Comment($this->lang->freeze));
                $document->add(new Image("templates/icons/unfreeze.gif", "Unfreeze"));
                $document->add(new Link("myadopts/freeze/{$adopt->getAdoptID()}/confirm", "Unfreeze this Adoptable", TRUE));
            }
            else{
                $document->add(new Image("templates/icons/unfreeze.gif", "Not Frozen"));
                $document->add(new Comment("Not Frozen<br><br>"));
                $document->add(new Comment($this->lang->freeze));
                $document->add(new Image("templates/icons/freeze.gif", "Greeze"));
                $document->add(new Link("myadopts/freeze/{$adopt->getAdoptID()}/confirm", "Freeze this Adoptable", TRUE));
            }
            $document->add(new Comment("<br><br>"));
            $document->add(new Image("templates/icons/warning.gif"));
            $document->addLangvar($this->lang->freeze_warning);
        }
    }
}

If this doesn't work then it's a problem with something else.

One thing you can try is to go to the image link and see if it gives you an error when generating it. So go to yoursite.com/adoptimage/1, or whatever ID you have for a pet. If there is then hopefully it'll tell you so we know what it is and can write that off, or see if the image is the issue lol
 
You can also try replacing your model/domainmodel/ownedadoptable.php:

PHP:
<?php

namespace Model\DomainModel;
use Resource\Core\Model;
use Resource\Core\Registry;
use Resource\Exception\InvalidActionException;
use Resource\GUI\Component\Image;
use Resource\Utility\Date;

class OwnedAdoptable extends Adoptable{
    
    const IDKEY = "aid";
    protected $aid;
    protected $name;
    protected $owner;
    protected $currentlevel;
    protected $totalclicks;
    protected $code;
    protected $imageurl;
    protected $alternate;
    protected $tradestatus;
    protected $isfrozen; 
    protected $gender;
    protected $offsprings;
    protected $lastbred;
    protected $species;
    protected $lastupdate;
    protected $imglastupdate;

    protected $nextlevel;
    protected $voters;
 
    public function __construct($aid, $dto = NULL){     
        $mysidia = Registry::get("mysidia");
        if(!$dto){
            $dto = $mysidia->db->select("owned_adoptables", [], "aid = :aid", ["aid" => $aid])->fetchObject();
            if(!is_object($dto)) throw new AdoptNotfoundException("Owned Adoptable ID {$aid} does not exist or does not belong to the owner specified...");
        }
        $this->createFromDTO($dto);   
    }
    
    protected function createFromDTO($dto){
        parent::createFromDTO($dto);
        if($this->lastbred) $this->lastbred = new Date("@{$dto->lastbred}");
    }

    public function getAdoptID(){
        return $this->aid;
    }

    public function getLastUpdate(){
        return $this->lastupdate;
    }

    public function getImgLastUpdate(){
        return $this->imglastupdate;
    }
    
    public function getSpecies(){
        return new Adoptable($this->id);
    }
    
    public function getSpeciesID(){
        return $this->id;
    }

    public function getName(){
        return $this->name;
    }
    
    public function setName($name, $assignMode = ""){
        if($assignMode == Model::UPDATE) $this->save("name", $name);
        $this->name = $name;
    }

    public function getOwner($fetchMode = ""){
        if(!$this->owner) return NULL;
        if($fetchMode == Model::MODEL) return new Member($this->owner);
        return $this->owner;
    }
    
    public function setOwner($owner, $assignMode = ""){
        if($assignMode == Model::UPDATE) $this->save("owner", $owner);
        $this->owner = $owner;
    }
    
    public function isOwner(User $user = NULL){
        if(!$user || !($user instanceof Member)) return FALSE;
        return ($this->owner == $user->getID());
    }
    
    public function isOwnerID($userID = 0){
        if(!$userID) return FALSE;
        return ($this->owner == $userID);
    }

    public function getOwnerName(){
        if(!$this->owner) return NULL;
        return $this->getOwner(Model::MODEL)->getUsername();
    }
 
    public function getCurrentLevel($fetchMode = ""){
        if($fetchMode == Model::MODEL) return new Level($this->id, $this->currentlevel);
        else return $this->currentlevel;
    }
    
    public function setCurrentLevel($level, $assignMode = ""){
        $this->currentlevel = $level;
        if($assignMode == Model::UPDATE){
            $this->save("currentlevel", $this->currentlevel);
            $this->updateAlternate($assignMode);
        }
    }
    
    public function getTotalClicks(){
        return $this->totalclicks;
    }
    
    public function setTotalClicks($clicks, $assignMode = ""){
        if($assignMode == Model::UPDATE) $this->save("totalclicks", $clicks);
        $this->totalclicks = $clicks;
    }
    
    public function setLevelAndClicks($level, $clicks, $assignMode = ""){
        $this->setCurrentLevel($level, $assignMode);
        $this->setTotalClicks($clicks, $assignMode);
    }
    
    public function getCode(){
        return $this->code;
    }
    
    public function getImageURL($fetchMode = ""){
        if($fetchMode == Model::GUI) return new Image($this->imageurl);
        else return $this->imageurl;
    }
    
    public function getAlternate($fetchMode = ""){
        if($fetchMode == Model::MODEL) return new AdoptAlternate($this->alternate);
        return $this->alternate;
    }
    
    public function setAlternate(AdoptAlternate $alternate, $assignMode = ""){
        $this->imageurl = $alternate->getImage();
        $this->alternate = $alternate->getALID();
        if($assignMode == Model::UPDATE){
            $this->save("imageurl", $this->imageurl);
            $this->save("alternate", $this->alternate);
        }
    }

    public function updateAlternate($assignMode = ""){
        $alternate = $this->generateAlternate();
        if($alternate){
            $this->imageurl = $alternate->getImage();
            $this->alternate = $alternate->getALID();
        }
        else{
            $this->imageurl = NULL;
            $this->alternate = 0;
        }

        if($assignMode == Model::UPDATE){
            $this->save("imageurl", $this->imageurl);
            $this->save("alternate", $this->alternate);
        }
    }
    
    public function getTradeStatus(){
        return $this->tradestatus;
    }
    
    public function setTradeStatus($status, $assignMode = ""){
        if($assignMode == Model::UPDATE) $this->save("tradestatus", $status);
        $this->tradestatus = $status;
    }
    
    public function isFrozen(){
        return $this->isfrozen;
    }
    
    public function setFrozen($frozen = TRUE, $assignMode = ""){
        if($assignMode == Model::UPDATE) $this->save("isfrozen", $frozen);
        $this->isfrozen = $frozen;
    }
    
    public function getGender($fetchMode = ""){
        if($fetchMode == Model::GUI) return new Image("images/{$this->gender}.png");
        else return $this->gender;
    }
    
    public function getOffsprings(){
        return $this->offsprings;
    }
    
    public function setOffsprings($offsprings = 1, $assignMode = ""){
        $this->offsprings = $offsprings;
        if($assignMode == Model::UPDATE) $this->save("offsprings", $this->offsprings);
    }
    
    public function getLastBred($format = NULL){
        return $format ? $this->lastbred->format($format) : $this->lastbred;
    }
    
    public function setLastBred($lastBred = 0, $assignMode = ""){
        if($assignMode == Model::UPDATE) $this->save("lastbred", $lastBred);
        if($lastBred > 0) $this->lastbred = new Date("@{$lastBred}");   
    }
    
    public function getImage($fetchMode = ""){
        $home = SCRIPTPATH."/";
        if($this->getLastUpdate() != $this->getImgLastUpdate() || !file_exists("C:\\wamp64\\www\\bean-pets\\images\\adopts\\pets\\{$this->getAdoptID()}.png")){
            return "{$home}adoptimage/view/{$this->getAdoptID()}";
        }
        else{
            return "{$home}images/adopts/pets/{$this->getAdoptID()}.png?{$this->getImgLastUpdate()}";
        }       
    }
 
      public function hasNextLevel(){
        try{
            $this->nextlevel = new Level($this->id, $this->currentlevel + 1);
            return TRUE;
        }
        catch(LevelNotfoundException $lne){
            return FALSE;
        }
    }
    
    public function getNextLevel(){
        if(!$this->nextlevel) return FALSE;
        return $this->nextlevel;
    }
    
    public function getLevelupClicks(){
        if(!$this->nextlevel) return FALSE;
        return $this->nextlevel->getRequiredClicks() - $this->totalclicks;
    }

    public function generateAlternate(){
        if(!$this->canUseAlternate($this->currentlevel)) return;
        $alternateModels = $this->filterAlternates();
        $totalChance = 100;
        $currentNumber = 0;
        $winningNumber = rand($currentNumber, $totalChance - 1);
        foreach($alternateModels as $alternateModel){
            $nextNumber = (int)$alternateModel->getChance() + $currentNumber;
            if($winningNumber >= $currentNumber && $winningNumber < $nextNumber) return $alternateModel;
            $currentNumber = $nextNumber;
        }
    }

    private function filterAlternates(){
        $alternateModels = $this->getAlternatesForLevel($this->currentlevel);
        $filterGender = ($this->gender == "f") ? "female" : "male";
        $filterALID = $this->alternate;
        $filterClosure = function($alternateModel) use ($filterGender, $filterALID){
            return (!$alternateModel->getItem() && ($alternateModel->getGender() == "both" || $alternateModel->getGender() == $filterGender) && (!$alternateModel->getLastAlt() || $alternateModel->getLastAlt() == $filterALID));
        };
        return array_filter($alternateModels->toArray(), $filterClosure);
    }
    
    public function hasVoter($user, Date $date = NULL){
        if(!$date) $date = new Date;       
        $mysidia = Registry::get("mysidia");
        
        if($user instanceof Member){ 
            $whereClause = "adoptableid = '{$this->aid}' AND userid = '{$user->getID()}' AND date = '{$date->format('Y-m-d')}'";
        }
        else{
            $ip = $mysidia->secure($_SERVER['REMOTE_ADDR']);
            $whereClause = "adoptableid = '{$this->aid}' AND ip = '{$ip}' AND date = '{$date->format('Y-m-d')}'";
        }   
        
        $void = $mysidia->db->select("vote_voters", ["void"], $whereClause)->fetchColumn();
        if(is_numeric($void)) return TRUE;
        else return FALSE;       
    }
    
    public function pound(){
        $mysidia = Registry::get("mysidia");
        if(!$this->owner) throw new InvalidActionException("The adoptable is already pounded");
        $this->updatePound();
        $this->owner = 0;
        $mysidia->db->update("owned_adoptables", ["owner" => $this->owner], "aid = '{$this->aid}'");
    }
    
    protected function updatePound(){
        $mysidia = Registry::get("mysidia");
        $today = new Date;
        $mysidia->db->insert("pounds", ["aid" => $this->aid, "firstowner" => $this->owner, "lastowner" => $this->owner,
                                        "currentowner" => 0, "recurrence" => 1, "datepound" => $today->format('Y-m-d'), "dateadopt" => NULL]);             
    }
    
    protected function save($field, $value){
        $mysidia = Registry::get("mysidia");
        $mysidia->db->update("owned_adoptables", [$field => $value], "aid = '{$this->aid}'");
    }
}

Of course make sure to go through and change all image links to your own URL haha
 
When I go to adoptimage it gives me invalid action specefied.

Also this error on another page: Fatal Error: Class Controller\Main\picuploadsController either does not exist, or has its include path misconfigured!

Get this at the top of the page.

elseif($adopt->currentlevel == 1){ $images1 = array('https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', 'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', 'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', 'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\' 'lineart.png'); $images = array_merge($images1, $images2, $images3, $images4); if($adopt->species == "floof"){ if($adopt->currentlevel == 1){ $composed_image->setIteratorIndex(0); $composed_image->setImageBackgroundColor('transparent'); $composed_image->setIteratorIndex(1); $clut->newImage(1, 1, new \ImagickPixel("$adopt->body")); // Colours the body $composed_image->clutImage($clut); $clut->destroy(); $composed_image->compositeImage( new \Imagick($images[1]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour $composed_image->setIteratorIndex(2); $clut->newImage(1, 1, new \ImagickPixel("$adopt->body_colour1")); // Colours the body colour 1 $composed_image->clutImage($clut); $clut->destroy(); $composed_image->compositeImage( new \Imagick($images[2]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour $composed_image->setIteratorIndex(3); $clut->newImage(1, 1, new \ImagickPixel("$adopt-> body_colour2")); // Colours body colour 2 $composed_image->clutImage($clut); $clut->destroy(); $composed_image->compositeImage( new \Imagick($images[3]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour $composed_image->setIteratorIndex(3); $clut->newImage(1, 1, new \ImagickPixel("$adopt-> body_marking1")); // Colours body marking 1 $composed_image->clutImage($clut); $clut->destroy(); $composed_image->compositeImage( new \Imagick($images[3]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour $composed_image->evaluateImage(\Imagick::EVALUATE_MULTIPLY, $adopt->body_marking1_opacity, \Imagick::CHANNEL_ALPHA); $composed_image->setIteratorIndex(4); $clut->newImage(1, 1, new \ImagickPixel("$adopt->wings_marking1_colour")); // Colours body marking 1 $composed_image->clutImage($clut); $clut->destroy(); $composed_image->compositeImage( new \Imagick($images[4]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour $composed_image->evaluateImage(\Imagick::EVALUATE_MULTIPLY, $adopt->body_marking1_colour, \Imagick::CHANNEL_ALPHA); $composed_image->setIteratorIndex(6); $clut->newImage(1, 1, new \ImagickPixel("$adopt->body_colour2")); // Colours body marking 1 $composed_image->clutImage($clut); $clut->destroy(); $composed_image->compositeImage( new \Imagick($images[6]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour
 
Could you upload the files for me please? You can attach them to a post here. I'll have a look in them, might be easier than trying to find the error without having access haha
 
Could you upload the files for me please? You can attach them to a post here. I'll have a look in them, might be easier than trying to find the error without having access haha
I think these are all of them? Tysm!!
 

Attachments

  • ownedadoptableviewmodel.php
    2 KB · Views: 2
  • ownedadoptable.php
    9.8 KB · Views: 2
  • myadoptsview.php
    10.7 KB · Views: 1
  • adoptimageview.php
    637 bytes · Views: 1
  • adoptimagecontroller.php
    7.3 KB · Views: 2
Try these? There were a few errors but I think I got them all so hopefully this works! Also, most of the issues were in adoptimagecontroller with the pet layers so here's a little guide for how to use them.

The first layer is 0, not 1. On my site I have a background for pets, the default background is a blank transparent image so that's why I use the below. I removed it from your file as you don't have a background:

PHP:
$composed_image->setIteratorIndex(0);
$composed_image->setImageBackgroundColor('transparent');

When colouring a normal layer that does not use opacity, you use this:

PHP:
$composed_image->setIteratorIndex(1);
                $clut->newImage(1, 1, new \ImagickPixel("$adopt->wings_colour2")); // Colours the back wing second colour
                $composed_image->clutImage($clut);
                $clut->destroy();
                $composed_image->compositeImage( new \Imagick($images[1]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour

When colouring a marking layer that DOES use opacity, you use this:

PHP:
$composed_image->setIteratorIndex(3);
                $clut->newImage(1, 1, new \ImagickPixel("$adopt->wings_marking1_colour")); // Colours wing marking 1
                $composed_image->clutImage($clut);
                $clut->destroy();
                $composed_image->compositeImage( new \Imagick($images[3]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour
                $composed_image->evaluateImage(\Imagick::EVALUATE_MULTIPLY, $adopt->wings_marking1_opacity, \Imagick::CHANNEL_ALPHA);

Of course you need to change the variables to the correct one ($adopt->wings_marking1_colour, $adopt->wings_marking1_opacity, etc.)

You also need to make sure that the 2 numbers are assigned to the correct layer. This is the part that always takes me the longest as I need to count them constantly to make sure I'm not accidentally colouring the lineart lol. So in the above snippet that colours the wing marking, you need to change setIteratorIndex(3) and new \Imagick($images[3]) to use the right number.

You can find the number by looking at this section:

PHP:
$images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3

And counting the lines. I like to put hashtags with the number every so often to remember what the line is, but if you add more layers you need to remember to go back and recount/make sure they're assigned correctly. And remember it starts at 0.

You also need to build the adopt from the back layer. So body colour would go at the back, then markings on top, and then the lineart.

Hopefully that's enough to get you going!
 

Attachments

  • ownedadoptableviewmodel.php
    2 KB · Views: 4
  • ownedadoptable.php
    9.5 KB · Views: 3
  • adoptimageview.php
    637 bytes · Views: 3
  • myadoptsview.php
    10.7 KB · Views: 3
  • adoptimagecontroller.php
    5.5 KB · Views: 3
Try these? There were a few errors but I think I got them all so hopefully this works! Also, most of the issues were in adoptimagecontroller with the pet layers so here's a little guide for how to use them.

The first layer is 0, not 1. On my site I have a background for pets, the default background is a blank transparent image so that's why I use the below. I removed it from your file as you don't have a background:

PHP:
$composed_image->setIteratorIndex(0);
$composed_image->setImageBackgroundColor('transparent');

When colouring a normal layer that does not use opacity, you use this:

PHP:
$composed_image->setIteratorIndex(1);
                $clut->newImage(1, 1, new \ImagickPixel("$adopt->wings_colour2")); // Colours the back wing second colour
                $composed_image->clutImage($clut);
                $clut->destroy();
                $composed_image->compositeImage( new \Imagick($images[1]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour

When colouring a marking layer that DOES use opacity, you use this:

PHP:
$composed_image->setIteratorIndex(3);
                $clut->newImage(1, 1, new \ImagickPixel("$adopt->wings_marking1_colour")); // Colours wing marking 1
                $composed_image->clutImage($clut);
                $clut->destroy();
                $composed_image->compositeImage( new \Imagick($images[3]), \Imagick::COMPOSITE_DSTIN, 0, 0 ); // Keeps within colour
                $composed_image->evaluateImage(\Imagick::EVALUATE_MULTIPLY, $adopt->wings_marking1_opacity, \Imagick::CHANNEL_ALPHA);

Of course you need to change the variables to the correct one ($adopt->wings_marking1_colour, $adopt->wings_marking1_opacity, etc.)

You also need to make sure that the 2 numbers are assigned to the correct layer. This is the part that always takes me the longest as I need to count them constantly to make sure I'm not accidentally colouring the lineart lol. So in the above snippet that colours the wing marking, you need to change setIteratorIndex(3) and new \Imagick($images[3]) to use the right number.

You can find the number by looking at this section:

PHP:
$images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3

And counting the lines. I like to put hashtags with the number every so often to remember what the line is, but if you add more layers you need to remember to go back and recount/make sure they're assigned correctly. And remember it starts at 0.

You also need to build the adopt from the back layer. So body colour would go at the back, then markings on top, and then the lineart.

Hopefully that's enough to get you going!
The manage adopts page works, but the images don't still. Do I need to assign the hexes manually to each adopt or will they just load the defaults?
 

Attachments

  • Screenshot (25).png
    Screenshot (25).png
    109 KB · Views: 4
The manage adopts page works, but the images don't still. Do I need to assign the hexes manually to each adopt or will they just load the defaults?
So long as the adopt has a hex value in the database it should work with that colour. Make sure it's a full hex with a hash in front of it like, '#000000'. Also make sure the adopt is level 1 and not 0 because we set up level 1 and left level 0 blank. I went on your site and went to /adoptimage/view/9 and got this error:

2023-11-24 03_13_27-Emotidogs and 7 more pages - Personal - Microsoft​ Edge.png

So this is what we need to fix lol. I think it might be because the adopt is level 0 tbh. As we left that blank the code doesn't know what to do with this line:

PHP:
$composed_image = new \Imagick($images);

Technically, if the adopt is level 0, 2, 3, 4, or 5, the $images variable is blank. If you don't want to make the adopt level 1, you can just copy:

PHP:
$images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3

to level 0.

So replace if($adopt->species == "floof"){

with:

PHP:
if($adopt->species == "floof"){

            if($adopt->currentlevel == 0){
                $images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3
            }
            elseif($adopt->currentlevel == 1){
                $images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3
            }
            elseif($adopt->currentlevel == 2){
                //Snipped for length
            }
            elseif($adopt->currentlevel == 3){
              //Snipped for length
            }
            elseif($adopt->currentlevel == 4){
                //Snipped for length
            }
            elseif($adopt->currentlevel == 5){
                //Snipped for length
            }
        }

Make sure you get all of it because if you accidentally leave a stray curly bracket ( {} ) it will break. Code is fussy haha. And earlier that was the issue in a few files, stray curly brackets and semi-colons.
 
So long as the adopt has a hex value in the database it should work with that colour. Make sure it's a full hex with a hash in front of it like, '#000000'. Also make sure the adopt is level 1 and not 0 because we set up level 1 and left level 0 blank. I went on your site and went to /adoptimage/view/9 and got this error:

View attachment 679

So this is what we need to fix lol. I think it might be because the adopt is level 0 tbh. As we left that blank the code doesn't know what to do with this line:

PHP:
$composed_image = new \Imagick($images);

Technically, if the adopt is level 0, 2, 3, 4, or 5, the $images variable is blank. If you don't want to make the adopt level 1, you can just copy:

PHP:
$images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3

to level 0.

So replace if($adopt->species == "floof"){

with:

PHP:
if($adopt->species == "floof"){

            if($adopt->currentlevel == 0){
                $images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3
            }
            elseif($adopt->currentlevel == 1){
                $images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3
            }
            elseif($adopt->currentlevel == 2){
                //Snipped for length
            }
            elseif($adopt->currentlevel == 3){
              //Snipped for length
            }
            elseif($adopt->currentlevel == 4){
                //Snipped for length
            }
            elseif($adopt->currentlevel == 5){
                //Snipped for length
            }
        }

Make sure you get all of it because if you accidentally leave a stray curly bracket ( {} ) it will break. Code is fussy haha. And earlier that was the issue in a few files, stray curly brackets and semi-colons.
So I changed the level to one and it broke the my adopts table and the one in admin cp. So deleted that one and edited the hexes in phpmyadmin and the image still won't load.
 

Attachments

  • Screenshot (28).png
    Screenshot (28).png
    195.6 KB · Views: 4
  • Screenshot (29).png
    Screenshot (29).png
    104.5 KB · Views: 4
So I changed the level to one and it broke the my adopts table and the one in admin cp. So deleted that one and edited the hexes in phpmyadmin and the image still won't load.
Oh you also need to fill in the other fields. You need to name body or it won't know what layer to use for the line art. It also looks like you are trying to call for a field called colours in the code but that doesn't exist. Also it seems like you're trying to use body_colour2 for the image name which wouldn't work unless you named the images after specific hexes.

So I think you need to go over the array and see what your files are called and double check they match up.

PHP:
$images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3

From the above you're trying to call for fields called:

colours (which doesn't exist)
body_colour2 (which you probably don't want), etc.

Try something like this (attached file), and make sure the folders are set up correctly. Here are the folders the code will accept in the file I uploaded. Folder names in bold:

  • picuploads
    • dog_images
      • adult
        • colours
          • [body_name]_colour2.png
          • [body_name]_colour1.png
        • markings
          • [body_name]
            • [marking_name].png
        • lines
          • [body_name]_lineart.png
Make sure you rename the layers correctly for what type of body you're wanting, etc. For example change every [body_name] to fluffy_body and then in the DB make sure the body field is set to fluffy_body.

Also make sure to add a blank transparent image for the marking called 'none.png' and put 'none' in the DB field for marking. I don't think it likes it if there's no entry and you try to colour something. You can also use that for if the body doesn't use colour2. Just have a transparent image the same size as the pet.
 

Attachments

  • adoptimagecontroller.php
    7 KB · Views: 1
Oh you also need to fill in the other fields. You need to name body or it won't know what layer to use for the line art. It also looks like you are trying to call for a field called colours in the code but that doesn't exist. Also it seems like you're trying to use body_colour2 for the image name which wouldn't work unless you named the images after specific hexes.

So I think you need to go over the array and see what your files are called and double check they match up.

PHP:
$images = array('http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour2 . 'body_colour2.png', #0
                'http://emotidogs.online/picuploads/dog_images/adult/colours/' . $adopt->colours . '\\' . $adopt->body_colour1 . 'body_colour1.png', #1
                'https://emotidogs.online/picuploads/dog_images/adult/markings/' . $adopt->markings . '\\' . $adopt->body_marking1 . 'body_marking1.png', #2
                'http://emotidogs.online/picuploads/dog_images/adult/lineart.png' . $adopt->body . '\\lineart.png'); #3

From the above you're trying to call for fields called:

colours (which doesn't exist)
body_colour2 (which you probably don't want), etc.

Try something like this (attached file), and make sure the folders are set up correctly. Here are the folders the code will accept in the file I uploaded. Folder names in bold:

  • picuploads
    • dog_images
      • adult
        • colours
          • [body_name]_colour2.png
          • [body_name]_colour1.png
        • markings
          • [body_name]
            • [marking_name].png
        • lines
          • [body_name]_lineart.png
Make sure you rename the layers correctly for what type of body you're wanting, etc. For example change every [body_name] to fluffy_body and then in the DB make sure the body field is set to fluffy_body.

Also make sure to add a blank transparent image for the marking called 'none.png' and put 'none' in the DB field for marking. I don't think it likes it if there's no entry and you try to colour something. You can also use that for if the body doesn't use colour2. Just have a transparent image the same size as the pet.
Okay so I'm pretty sure I added everything correctly, but it still isn't working.

My folders:

  • picuploads
    • dog_images
      • adult
        • colours
          • fluffy_body_colour2.png
          • fluffy_body_colour1.png
          • none.png
        • markings
          • fluffy_body
            • marking_1.png
            • none.png
        • lines
          • fluffy_body_lineart.png
 

Attachments

  • Screenshot (29).png
    Screenshot (29).png
    104.5 KB · Views: 1
  • Screenshot (30).png
    Screenshot (30).png
    190.7 KB · Views: 1
  • 1700854139322.png
    1700854139322.png
    197.2 KB · Views: 1
  • adoptimagecontroller.php
    7.1 KB · Views: 0
The db fields need to be

body
body_colour1
etc

And the entry needs to be fluffy_body. That way you can change the type of body by changing fluffy_body to whatever you want. Like this screenshot:

2023-11-24 23_54_51-localhost _ MySQL _ bean_pets _ adopts_owned_adoptables _ phpMyAdmin 5.2.0...png
 
The db fields need to be

body
body_colour1
etc

And the entry needs to be fluffy_body. That way you can change the type of body by changing fluffy_body to whatever you want. Like this screenshot:

View attachment 688
Ooh that makes more sense. Does $adopt->body stay the same then in the controller?
 
Yep! You can use $adopt->[field name] to call for any column that you have so that would be how you added more layers if you wanted them.
 
Yep! You can use $adopt->[field name] to call for any column that you have so that would be how you added more layers if you wanted them.
Ohh I see. I'm not sure what I'm missing because the image still doesn't work. ;_;

Edit: Okay, so I had someone super sweet on fiverr help me free of charge, so apparently it isn't a code problem and is instead is an issue with my web host not loading imagemagick correctly

Edit 2: I installed imagemagick through terminal and it still isn't working.
 

Attachments

  • adoptimagecontroller.php
    7.1 KB · Views: 1
Last edited:
Ohh I see. I'm not sure what I'm missing because the image still doesn't work. ;_;

Edit: Okay, so I had someone super sweet on fiverr help me free of charge, so apparently it isn't a code problem and is instead is an issue with my web host not loading imagemagick correctly

Edit 2: I installed imagemagick through terminal and it still isn't working.
Sorry for late reply, been super ill lol. Are your database fields for colour called 'fluffy_body_colour2' and 'fluffy_body_colour1'? Or body_colour2 and body_colour1? Because if they are not called fluffy_body then the code is referencing the wrong names.

That's the only issue I can potentially see with it at this point?
 

Attachments

  • adoptimagecontroller.php
    7.1 KB · Views: 1
Oh, also make sure that there is a database column for 'species' and that the pet you're trying to make is a species called 'floof' because that's in the code and it wouldn't work if there is either no species field or species is set to something else.
 
Oh, also make sure that there is a database column for 'species' and that the pet you're trying to make is a species called 'floof' because that's in the code and it wouldn't work if there is either no species field or species is set to something else.
Thanks, added it and still nothing. This has to be an issue with my web host. Going to try a different one and hope it works.
 
Oh, also make sure that there is a database column for 'species' and that the pet you're trying to make is a species called 'floof' because that's in the code and it wouldn't work if there is either no species field or species is set to something else.
Guess whose site still doesn't work even after switching web hosts?? :')
 

Attachments

  • Screenshot (48).png
    Screenshot (48).png
    101.9 KB · Views: 4

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