Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This patch splits the image api from the gd2 image manipulation functions to start with.
Only api functions remain inside image.inc, and image.gd.toolkit.inc should be copied from the next comment.
To review:
- Apply the patch as you normally do;
- copy the new image.gd.toolkit.inc into your includes directory;
Try to upload some images and see if it works... :-) (It does here at least)
The underlying thought are to extend the possibilities of the image api, tmo anipulate your images on the fly through a drupal UI after uploading them.
Comment | File | Size | Author |
---|---|---|---|
#32 | drupal_148346.patch | 2.14 KB | drewish |
#30 | 148346_0.patch | 18.87 KB | drewish |
#29 | image.imagemagick.inc_.txt | 12.31 KB | drewish |
#26 | 148346.patch | 17.53 KB | drewish |
#23 | image-api_0.patch | 17.85 KB | Stefan Nagtegaal |
Comments
Comment #1
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedErr...
It was image.gd.inc instead of image.gd.toolkit.inc..
So, in hort to review you do:
- apply the patch;
- copy image.gd.inc.patch into includes/ and rename it to image.gd.inc;
that's all, enjoy!
Comment #2
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedNew patch, now everything is in the patch itself including the new added image.gd.inc file.
To review:
- apply the patch;
And that's nearly it. It's a pretty trivial patch, nothing special. But there is more to come when this hits the trunk..
Comment #3
ChrisKennedy CreditAttribution: ChrisKennedy commentedIt appears that the patch in #3 does not include the new file - I think you need to put the -N flag before your -F^f.
Comment #4
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedAnother attaempt to make the right patch..
this should do it! :-)
Comment #5
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedthe patch before had a bug when used in a new installation of drupal.
This one fixes that.
Ready for review! :-)
Comment #6
Gurpartap Singh CreditAttribution: Gurpartap Singh commentedThe patch is straight forward, but:
You could change it to:
'title' => t('Built-in GD2 toolkit')
Could just be changed to:
Removed the message; and the if () check, because it's always going to have a value, either the one set by the user, or the default i.e. 'gd'.
Some more features could be introduced so that contributed modules can make use of introducing new libraries, that can be a separate patch though.
Comment #7
dikini CreditAttribution: dikini commentedsimple patch. improves consistency. Allows cleaner imagemagic integration. works.
Comment #8
drewish CreditAttribution: drewish commentedHumm, I couldn't apply the patch...
I'll give it a try on another machine.
Comment #9
drewish CreditAttribution: drewish commentedI think this is an excellent idea. It makes for a much cleaner interface.
I made most of the changes Gurpartap Singh pointed out but ended up restoring a good chunk of the original image_get_toolkit() function. The primary reason being that users can delete the toolkit files. I get bug reports on the image module from users who'd deleted the imagemagik toolkit and couldn't get the setting to switch back. If the file's missing there's no toolkit.
Comment #10
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedOkay, here is another updated patch which includes above concerns, but instead of having an image.gd.inc file, we now have a image.gd2.inc file (because of backwards compatibility and it's GD2 not GD).
There is no update/upgrade path needed. This patch works really well, and I encourage people to review this so it get's committed. After that I'll try to add some new functionality to the image api, so our image handling will be a little better.
Comment #11
drewish CreditAttribution: drewish commentedSteef, I'm unclear why you changed the name from gd to gd2... It is more accurate but you will need an update to change the
image_toolkit
variable's value fromgd
togd2
.Comment #12
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedForget my last patch.. After discussing with Drewish, his patch is preferable above mine..
We tested this throughly, and after one other review this should be RTBC..
For everybody who's interested, http://drupal.org/node/148346#comment-254671 (drewish followup #9) is the patch to apply and test..
Comment #13
drewish CreditAttribution: drewish commentedokay so steef and i talked on IRC and decided that the patch on #9 is the way to go.
Comment #14
webchickWow, this is really one of those "You mean it didn't already work like this?!" patches. It makes far more sense for gd-specific functions to be in image.gd.inc than in image.inc. +1.
Functionality-wise, I tested the two places in core where the image API is called: user pictures and upload.module (when max definitions are specified). In both cases, everything worked as expected.
Patch #9 is RTBC.
Comment #15
sime/subscribing (late)
Comment #16
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedThis patch is superseeded by "Improve image-api: Image toolkits should be implemented as modules", which gives us much more control, flexibility and a cleaner implementation/code.
Marking this one as "Duplicate"
Comment #17
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedWell, re-opening this issue because Dries rehected this issue to get in.
Let's make this right now...
Updated patch to apply against HEAD. Setting status back to RTBC as that was it's current state before I marked it as a duplicate.
In short what the patch does:
- removes cruft from the image api;
- properly adds t()'s to all translatable messages;
- refactored image.inc to be more like an api, so I moved all GD toolkit specific code to image.gd.inc;
Please get this in...
Comment #18
Gábor HojtsyReviewed the code:
- The gd file should have a @file comment, it does not have this phpdoc tag there now
- The image_gd_info() function could use a short explanation. Is it a hook implementation?
- The t() change I see with the watdog() call is definitely not right. Watchdog() calls *should not* have t()-ed strings (possibly except their last link parameter) in Drupal 6, as they are localized on display, not on logging.
Otherwise this seems like a logical code cleanup (so IMHO it is on track to be committed) but I don't see how this provides any new possibilities, unlike how others pointed out.
Comment #19
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commented@Gabor: First of all, this patch do not - in any way - add new possibilities. Unfortunatly the patch that does introduced toolkits as modules (and *much* more flexibility to work with), ended up to not be committed for drupal 6. So, I'm trying to pave the way for a nice and clean API in D6, which could be used as a base to implement more image manipulation features in the future.
I updated the patch:
- added @file php doc, which seem to have been missed;
- added a short but descriptive message to image_gd_info();
- and changed the t() calls around the watchdog messages (I missed it when this got committed, sorry);
Now, we are ready for review again! :-) Pls commit when you like, so we can further improve things step by step...
Comment #20
drewish CreditAttribution: drewish commentedSince there's a chance that this might get committed, I've gone through and modified all the comments to follow the coding standards.
I made one small change to image_rotate(). It now lets you pass a background color to the toolkit. The GD toolkit has always accepted the parameter which defaulted to 0.
Comment #21
Gábor Hojtsy@Stefan: well, dikini pointed out that this allows cleaner imagemagic integration, which I don't see. Anyway, this does not make this patch better or worse ;)
Seems like the latest patch has file comments misplaced. It has a GD2 file comment on top of image.inc, and a generic one on top of gd.inc.
Let's get reviews on the patch, so we have more eyes seeing it works, and I can commit it.
Comment #22
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedI swapped the comments as suggested by Goba.
Furthermore this is working very, very well.
Let's get someone else to review this, and let him (or her) set this RTBC. :-)
Comment #23
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commented** New patch file, which does include the image.gd.inc file */
I swapped the comments as suggested by Goba.
Furthermore this is working very, very well.
Let's get someone else to review this, and let him (or her) set this RTBC. :-)
Comment #24
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedThis is ready. It is tested pretty intensively by myself and I could not find anything that isn't working, or broken.
Please get this in..
Comment #25
Dries CreditAttribution: Dries commentedThis patch seems to introduce API changes (i.e. addition of background color) and should probably be postponed to D7 instead? Please motivate this change, and I'll consider to commit it.
Please rename $bg_color to $background.
Comment #26
drewish CreditAttribution: drewish commentedDries, technically, it is a change. All it does though is to correct one annoying wart in the image API. It does so by adding an additional, optional, parameter that defaults to its current behavior.
image_gd_rotate() already accepts the background color parameter but image_rotate() isn't providing anything to it. So if you wanted a white background on a rotation you had to call
image_toolkit_invoke('rotate', ...));
and pass it in yourself.Comment #27
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commented@Dries: there is no place in contrib, or core where
image_toolkit_invoke('rotate', $arguments)
is used. So, we aren't breaking anything.@drewish: thanks for updating this patch at my absense, I really appreciate you time, effort and thinking which helped me a lot while building the patch.
Comment #28
Dries CreditAttribution: Dries commentedI'm OK with committing this patch for D6 -- it doesn't break anything. However, I'd like to see us add some code comments to the top of image.inc, and maybe extend the code comments on top of image.gd2.inc to reference image.inc.
At the top of image.inc, it would be good to explain the purpose of this file, and the basic design of the image API. Specifically, it is worth explaining why it is important to use Drupal's API rather than using PHP's functions directly. Why would you _not_ want to use GD2 -- it's part of a standard PHP installation. Explain why other toolkits might be better?
It's also useful to explain that one can swap in different image backends, how that is done, what backends are supported out of the box. For developers, it's really useful to know this all works from a high-level point of view. Furthermore, it might also be useful to explain certain limitations -- can I have more than one active backend at the same time?
If we can add one or two paragraphs of text to the top of image.inc, then this makes for a good commit.
Thanks.
Comment #29
drewish CreditAttribution: drewish commentedfirst for anyone who's testing at home, here's an imagemagick toolkit that works with D6. re-roll to follow.
Comment #30
drewish CreditAttribution: drewish commentedpoked through the database.inc to get an idea of how to add a @defgroup. i haven't run it through the api.module but it looks like it should be alright.
when you know how something works docs are hard to write, i never know what questions to answer. hopefully someone can take a look at those and make sure they make sense.
Comment #31
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Good job.
Comment #32
drewish CreditAttribution: drewish commentedIt looks like you only committed part of the patch... if you didn't like my docs you could have just said so ;)
Comment #33
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #34
(not verified) CreditAttribution: commented