Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSD conversion to jpg #426

Closed
wilson12 opened this issue May 8, 2014 · 8 comments
Closed

PSD conversion to jpg #426

wilson12 opened this issue May 8, 2014 · 8 comments
Labels
Level: New Feature 🆕 This item involves the introduction of new functionality.

Comments

@wilson12
Copy link

wilson12 commented May 8, 2014

Not sure if this is an issue or not should the conversion happen automatically or should i modify the code
the bundle successfully does png to jpg,jpg to png
But for psd to jpg it seems to fail.

@makasim
Copy link
Collaborator

makasim commented May 8, 2014

Version 1.0 (current dev) does not allow to convert image format, even jpg to png. This feature was dropped while upgrading from 0.x versions (it is supported there). It will be re implemented later.

Cannot say anything about psd to jpg. sorry.

@ama3ing
Copy link

ama3ing commented May 9, 2014

@wilson12, @makasim I am not sure if GD supports .psd to .jpg. But seems like imagick has options to convert. Basically I can research more on this, but surely .psd to .jpg is out of bundle's scope.

@wilson12
Copy link
Author

wilson12 commented May 9, 2014

@Me1ifaro yes i am using imagick and it is converting them but it makes layer-0.jpg,layer-1.jpg,layer-2.jpg,layer-3.jpg and so on.
I modified the code vendor\imagine\imagine\lib\Imagine\Imagick\Imagine.php read function to this

public function read($resource)
{
if (!is_resource($resource)) {
throw new InvalidArgumentException('Variable does not contain a stream resource');
}

    try {
        $imagick = new \Imagick();
        //$imagick->readImageFile($resource);
        $meta_data = stream_get_meta_data($resource);
        $imagick->readImage("{$meta_data['uri']}[0]");
    } catch (\ImagickException $e) {
        throw new RuntimeException(
            'Could not read image from resource', $e->getCode(), $e
        );
    }

    return new Image($imagick);
}

But apparently this class Imagine.php is final.So i could not overwrite it. PSD to jpg conversion is done but now how to overwrite the final class. Where can i achieve the similar functionality.
(BTW This also helped in converting pdf to jpg with ghostscript installed in server).

@ama3ing
Copy link

ama3ing commented May 10, 2014

@wilson12, well, as I know Imagine\Imagic\Imagine class has no private or protected methods except createPalette (which I am sure you don't need). So I don't see any reason to extend it. In your situation I'd created separate service, responsible for conversion and all the stuff you need. If you need Imagine class just create private instance of it. Like:

<?php 
class PsdToJpgConverter
{
    private $imagine;

    public function getImagine()
    {
         if (null === $this->imagine) {
               $this->imagine = new \Imagine\Imagic\Imagine();
         }

         return $this->imagine;
    }
//....
}

Also, modifying vendor's code is bad idea, since this will not let you update it.

@ama3ing
Copy link

ama3ing commented May 10, 2014

@makasim and @havvg do you see image converter as filter, or something else? I'd like to proceed on this, since I need it in my project.

@havvg
Copy link
Contributor

havvg commented May 10, 2014

I only see this as a filter. The hell this feature caused in 0.x version was huge. There are so many side effects to take care of. The filter should take care of it and not interfere with the rest of the system.

@makasim
Copy link
Collaborator

makasim commented May 10, 2014

@Me1ifaro I cannot help much on this issue cuz I know little about it.

@makasim makasim added this to the v1.1 milestone May 22, 2014
@robfrawley robfrawley removed this from the v1.1-missed milestone Jan 25, 2017
@michellesanver
Copy link
Contributor

@ama3ing @wilson12 I am going through all issues to sort and prioritise. Is this still an issue for you? Since this is so old, please open a new issue if that is the case and we will prioritise accordingly. Thanks a lot! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Level: New Feature 🆕 This item involves the introduction of new functionality.
Projects
None yet
Development

No branches or pull requests

6 participants