Im looking for somthing that can belong to many many models and, hopfully, has all the resizing functionality built in too.
Wondering if there's any good suggestions out there, I don't want to pick the wrong one.
Or is it just worth building my own?
I wrote a pretty sweet image upload component a few years ago for Cake 1. I don't have a clue where the code is these days, but my friend Koa did a write up on it a while back:
http://labs.iamkoa.net/2007/10/23/image-upload-component-cakephp/
http://labs.iamkoa.net/2007/11/06/multiple-image-uploads-into-single-mysql-table-cakephp/
Might be something you can hack. It handles uploads, resizing (resize, crop, resize then crop, max, mix) and if I remember correctly, it might even do filters (flipping, inverse, greyscale).
I also ported the code to Zend framework (and PEAR file naming) for my new content management framework. It's all contained and much better now (does all the things I mentioned above and is pretty well documented). You can download that here (check out the ImageManipulator class. I think the FileUploader class has a dependency on my String utils class which you could easily remove if you want to use that.
Otherwise, I say roll your own. The component architecture in Cake was confusing to me at first so it could be a good learning XP if you don't know it yet. If you do, you can just grab someones uploader and convert it into a component for your Cake application.
Check out the Media plugin by #nperson https://github.com/davidpersson/media/wiki
https://thoughtwm.com/code/ for the image upload
&
http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/ for the image resizing
How about for getting EXIF/Meta info of the image?
Related
We want to add our company's watermark to pdf files (that are uploaded by users).
We found a couple PHP libraries for manipulating PDFs. We're currently using FPDF. It appears fairly straight-forward to add the watermark, but we're struggling to figure out how to remove it.
Is this a limitation of this library? Or is there a more general issue with PDFs that makes this difficult?
I used for basic manipulation FPDF, but once I tried a little bit the java itext library it's pretty awesome. And really I recommend to you further reading iText in action. Just give a try through the vogella tutorial. The time you take for this will be really improve yourself.
Specially you can use the PdfStamper for this purpose. I can share a basic usage in https://github.com/web20opensource/stamper
In something similar way like adding a new layer to a image, it's the same way for manipulation pdfs.... you're adding a new layer. And as the same happens in images you can't remove a layer after you have merged all the layers.
CodeIgniter - is there a GUI based library for cropping an image?
I want to select exactly what and where to crop. Ideally I want to be able to go to
mysite.com/manageImage/crop/example-image.jpg
and it would show the interface to crop it, then crop that image.
What you need to do is fine a good library then add it as a library in your CI structure. Then the manageimage controller's crop function will take image name as argument and invoke the cropping library to do its magic. Most of what you will need, since it comes with UI will mean that you need to have some integration effort.
Sadly cannot google and list libraries for you, but I hope you got an idea what direction to proceed.
One good lib that comes to mind is cropzoom
I am back again with a question in zend framework. Can someone explain me, how to generate thumbnail images in zend framework after uploading an image.
Thanks!
Zend itself seems will not provide this ability http://framework.zend.com/wiki/display/ZFPROP/Zend_Image+-+Eric+Potvin and propose to use http://www.imagemagick.org/script/index.php.
then you are free to use your own way
Not a purely Zend Framework answer, but lately I have found myself cheating like crazy, as follows.
I install phpThumb somewhere inside a web-accessible folder, say:
http://example.com/img/t/phpThumb.php
I make sure to configure phpThumb to use a cache folder:
/path/to/myapp/public/img/t/cache
which I chmod to be web-server writable.
Then I have a phpThumb view-helper that allows me to call an original image with some resize parameters:
<img src="<?php $view->phpThumb($origImgUrl, $desiredWidth, $desiredHeight) ?>">
All the view helper really does is transform the src url into one that runs through my phpThumb installation, making sure to add the cool (!) zoom-center parameter:
<img src="/img/t/phpThumb.php?src=origUrl&w=200&h=150&zc=1">
The first call to this image with these resize params results in a full GD/ImageMagick-driven resize, with the full performance hit. But subsequent calls for that image will pull from cache. Not as good as a request for a truly static image, but usually acceptable for my relatively low-volume purposes.
This is especially useful during design/development, when I am not sure precisely how big I want some front-end, eye-candy image to be. So I can just stash a single, relatively-large verison of my image (say 640x480) out in public/img/someBigImage.png and then resize at will.
It's a hack - probably better to perform this resizing on upload, as you are actually asking - but I must admit I have used it in a few spots. Don't tell anybody. ;-)
I'm using Drupal for the first time for a project at work. I'm finally getting my head wrapped around some of the core concepts, but when it comes to customizing output I'm unsure of how to proceed.
I have to build a fairly specialized image gallery. I've managed to cobble something workable together using Views2, but it's not quite where it needs to be. I'd like to write it from scratch, using SQL and actual PHP, rather than working through this web UI.
I figure I'll put this functionality in a new module. Is that right? Or is that an abomination to the Drupal world?
Edit:
Here's what I've got so far. I've created Image Gallery and Image content types with CCK. Images can be assigned to multiple galleries, via nodereference. I've got imagecache creating two sizes for each uploaded image - a thumbnail size and a gallery size.
Two gallery formats are required, but let's assume I'm going to have a carousel style for now, with some custom JQuery and CSS to match the rest of the site's look and feel. Clicking a thumb in the carousel-style navigator will load the full sized image above it.
Now, assuming such a thing does not exist, what is the recommended approach for creating it? Not how to code it, but where would this code live within the Drupal system?
It seems like views will do the job of creating the data you need - a list of all the images for the galleries, based on whatever criteria you need (taxonomy,author or whatever) and that the carousel part - adding the jquery and css could be done by using drupal's themeing system to change the output.
So as ar as 'where would the code live' I would say in your theme, rather than a module.
The views theming system is pretty comprehensive, if possibly a little overwhelming at first.
This looks like a good starting reference: http://www.group42.ca/theming_views_2_the_basics
You can do this. Views is great but will often only get you 90% of what you need out of the box.
You can do views theming, which can take you further, and you can write extentions to the views functionality (but that is not always easy).
There is nothing wrong with writing your own module in stead of views, in some cases it can increase performance. One tip if you are doing this is that you can see use the query that views creates in your custom module, this can save you having to work it out and write it yourself.
Yep, I'd put this in a module. I often wind up writing custom ones for specialised use cases.
Well since it is free software you are free to do (almost) whatever you want with it.
A good practice to decide if you should do it is:
Will the benefits that I will get from
a custom module divided by the time
I'm going to invest in it. Outweigh
the benefits / over time of a solution
that isn't ideal?
Or if you prefer to look it this way:
Custom Development Benefits Not 'ideal' solution benefits
--------------------------- > -----------------------------------
Development Time Time to install and adapt
Since normally the Time to install and adapt normally is smaller than the time to develop something from scratch, the common conclusion is to just use what is already there.
But by all means if you want to develop your own thing and have enough time, go ahead.
I am developing a new project in CodeIgniter (CI), and would like to find a CI solution to this current issue. I've got one image, which resembles a picture frame. I would like for uploaded images to be modified to have this frame in their background.
Example:
alt text http://www.sampsonresume.com/projects/visit-creation/vc-process.jpg
The first picture is the frame. The second is the uploaded image (after resizing/cropping), and the third is the combination of both, which I would like to accomplish.
If the images are going to be shown on your own website, it would probably be easier to simply use CSS (especially if your bottom image simply gives a border...). Of course, if you want people to be downloading these files with the frame, that's a different story.
I don't think CI has a built in method in the Image Manipulation class. But, that class is simply abstracts typically-used features from one of the three major PHP image libraries (GD, ImageMagick, and NetPBM). If you know what library you are using (I normally use GD for basic things like this...), then you'll just have to use their proprietary ways of doing this stuff.
You can even make your own library or extend the Image Manipulation class to add your own special features.
Also, there may be ways to do this in Zend (not sure, I'm not going to look it up either). But, there are easy ways to include Zend components into CI if you do find something.
Good luck man!
Agreed with Kyle -- your best bet is to extend the libraries already there. Take a look at ImageMagick "composite" command.
composite -gravity center smile.gif rose: rose-over.png
http://www.imagemagick.org/script/composite.php