Skip to content

Images GDHandler::convert() sample code does not work #5966

Description

@kenjis

From https://forum.codeigniter.com/showthread.php?tid=81803

https://codeigniter4.github.io/CodeIgniter4/libraries/images.html#converting-images

<?php
namespace App\Controllers;
class Home extends BaseController
{
    public function index()
    {
        \Config\Services::image('gd')
            ->withFile(WRITEPATH . 'img.jpg')
            ->convert(IMAGETYPE_PNG)
            ->save(WRITEPATH . 'img2.png');
    }
}
ErrorException

imagecreatefrompng(): &quot;/Users/kenji/work/codeigniter/CodeIgniter4/writable/img.jpg&quot; is not a valid PNG file [search →](https://www.duckduckgo.com/?q=ErrorException+imagecreatefrompng%28%29%3A+%26quot%3B%2FUsers%2Fkenji%2Fwork%2Fcodeigniter%2FCodeIgniter4%2Fwritable%2Fimg.jpg%26quot%3B+is+not+a+valid+PNG+file)

SYSTEMPATH/Images/Handlers/GDHandler.php at line 351

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions