-
Notifications
You must be signed in to change notification settings - Fork 379
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
Add file transformers to the file loader #57
Conversation
In this way, it is possible to pass an array of transformer to the data loader. Transformers can be used to create images for virtually any file type.
*/ | ||
public function __construct(ImagineInterface $imagine, $formats, $rootPath) | ||
public function __construct(ImagineInterface $imagine, $formats, $rootPath, $transofrmers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in the variable name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, you should typehint the array
poke |
ok this looks fine to me now. |
$info = pathinfo($absolutePath); | ||
if (isset($info['extension']) && strpos(strtolower($info['extension']), 'pdf') !== false) { | ||
//Check if Imagick extension is loaded | ||
if (!extension_loaded('Imagick')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not omit curly brackets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opps .. i also noticed another thing. i would prefer it if we would inject the Imagick instance .. i don't have experience with its API .. but i assume we could also call setFilename() instead of passing the absolute path to the constructor? could you do a PR to change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm actually it seems Imagine itself is using the same approach .. the Imagick OO API also seems a bit strange:
https://github.com/avalanche123/Imagine/blob/master/lib/Imagine/Imagick/Imagine.php
@avalanche123 do you have a tip for us here what would make the most sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. It would be better. I'm checkin the API and PR the changes!
Add file transformers to the file loader
Thank you for all the corrections, informations, lessons and for your patience ;) |
no problem .. thx for working through all of this. looking forward for other patches from you :) |
Great addition to the bundle! My usecase is that I want to create thumbnails of all pages, so any ideas on a PR for that? In theory it sounds simple, since the page number is hard-coded in PdfTransformer.php |
The thing is you are creating more than one image in your case. |
In my usecase I already know the exact amount of pages in the PDF, so what I would like to do is create a loop in Twig and do a call to the The |
It would indeed require even more. You would need to pass in options into Unless I'm getting it all wrong right now, I'm against such heavy changes in the |
Idea to reopen this issue , or should I create another issue for discussing the features? |
A new one, please. |
In this way, it is possible to pass an array of transformer
to the data loader.
Transformers can be used to create images for
virtually any file type.
This PR is a cleanup of previous posts and references #52.