Image processing with the atkFileAttribute
vigrx online cheap cialis levitra tramadol online cheap vicodin wellbutrin online free qwest ringtones cheap propecia free polyphonic ringtones free cool ringtones polyphonic ringtones mono ringtones hydrocodone online but adipex free alltel ringtones valium online tenuate online cheap phentermine alprazolam online order flexeril hgh online meridia online cheap ultram free ringtones funny ringtones cheap diethylpropion free qwest ringtones real ringtones lipitor online cheap ultracet tramadol online cialis online free sony ericsson ringtones free funny ringtones zoloft free music ringtones carisoprodol online zanaflex online free nokia ringtones lortab free motorola ringtones free samsung ringtones alltel ringtones free sharp ringtones soma online free mtv ringtones levitra online pharmacy online online free real ringtones cheap ambien cheap diethylpropion xanax online online lorazepam real ringtones punk ringtones buy albuterol cheap xanax fioricet didrex online free verizon ringtones ultracet online free tracfone ringtones cheap clomid ativan xanax online buy nexium sonyericsson ringtones clomid online adipex online cialis online hydrocodone online levitra online midi ringtones lisinopril online free wwe ringtones phentermine online tracfone ringtones sildenafil online verizon ringtones free midi ringtones phentermine online rivotril online vicodin celexa online free funny ringtones cheap flexeril hoodia online tenuate online prozac online free sprint ringtones cheap norco meridia online free sprint ringtones buy diazepam online fioricet free mp3 ringtones buy paxil buy zanaflex cheap alprazolam cheap soma cheap diazepam free wwe ringtones but zoloft buy lorazepam online norco free ringtones carisoprodol online qwest ringtones cheap clonazepam celexa online clonazepam online buy lipitor nokia ringtones cheap lisinopril cheap propecia nokia ringtones punk ringtones carisoprodol online ultram online sony ericsson ringtones tracfone ringtones zyban online hoodia online tramadol online cingular ringtones free jazz ringtones free alltel ringtones flexeril free nextel ringtones free kyocera ringtones free samsung ringtones free motorola ringtones meridia online xenical online sony ringtones paxil online sagem ringtones buy ativan cheap rivotril ortho online cheap celexa sharp ringtones cheap adipex cheap ortho but hydrocodone cheap propecia free cingular ringtones nextel ringtones free sagem ringtones adipex online punk ringtones buy didrex free sonyericsson ringtones cheap didrex diazepam online free samsung ringtones free sharp ringtones meridia online free mono ringtones cheap valium buy hgh nextel ringtones free funny ringtones lortab online but ultracet viagra online albuterol cheap vicodin free motorola ringtones cheap lorazepam ericsson ringtones mp3 ringtones free sonyericsson ringtones viagra online cheap cyclobenzaprine cheap vigrx wwe ringtones zoloft online clomid online fioricet online samsung ringtones cheap albuterol buy tramadol cheap xenical online alprazolam clonazepam online mp3 ringtones norco online online xanax free mtv ringtones qwest ringtones valium sildenafil online cheap zyban cheap alprazolam levitra online cheap soma cheap ortho xenical online cheap zyban
|
ATK Howto: Image processing with the atkFileAttribute
|
Intro
The atkFileAttribute can be used to upload images and other files into an ATK application. Sometimes however you will want to process files before they are uploaded.
In this howto we create a custom atkFileAttribute to handle this. As an example, we will do three things. First, we will make a thumbnail version of the uploaded image, and second, we make this thumbnail look Sepia, and finally, we want to add a small border around the generated thumbnail.
Requirements
All you need is to set up a node that contains at least an atkFileAttribute. Make sure you have a working sample before you start with this howto.
Your atkFileAttribute code may look something like the following:
$this->add(new atkFileAttribute("picture", atkconfig("atkroot")."pictures/"))
This example uses a field called 'picture' in the database to hold the file name, and the image itself will be uploaded to the pictures/ subdirectory of our application.
Creating a custom attribute
First, we create a custom attribute that derives from atkFileAttribute. If you need this attribute only once, you can place the code directly in the class.<yournode>.inc file of the node you want to use it in, but, assuming you want to reuse this attribute later, we store it as a separate attribute:
<bash>
[ivo@nikita workspace]$ cd <yourapplication>/modules/<yourmodule>
</bash>
You can in fact use any module you have; if you have a lot of custom attributes, you might want to consider creating an 'attriblib' module (as in 'library of attributes') or something along those lines to hold all the attributes that you create. For the rest of this howto, I'll assume that your application is called 'app' and your module is called 'attriblib'
After you decided what module to place the attribute in, create a subdirectory 'attributes':
<bash>
[ivo@nikita yourmodule]$ mkdir attributes/
</bash>
Now it's time to decide a name for the new attribute. For our sepia example, let's call it the 'sepiaAttribute'. Create a file called 'class.sepiaattribute.inc' in the attributes/ subdirectory with the following contents:
<?php
// Include the base class
useattrib("atkfileattribute");
class sepiaAttribute extends atkFileAttribute
{
}
?>
You now have a custom attribute which behaves identical to the atkFileAttribute, since we have not added any processing yet. But we can already add this attribute to our node.
Adding the attribute to the node
Open your node class, and add the following useattrib call:
useattrib("attriblib.sepiaattribute");
As you can see, you can use the modulename and the name of the attribute in the useattrib call. ATK will derive the actual location of the file from this identifier.
In your node, replace the atkFileAttribute with the sepiaAttribute like this:
$this->add(new sepiaAttribute("picture", atkconfig("atkroot")."pictures/"))
When you now browse your application, everything should appear unchanged. You've added a custom attribute, but it doesn't do anything custom yet, so it acts just like a regular atkFileAttribute.
Adding image processing
The atkFileAttribute contains a method called 'processFile'. By default this method does not do anything, but it can be implemented in custom attributes to do the processing.
To make the image Sepia, I googled a bit and found a useful 'class.image.php' on http://php.amnuts.com/index.php?do=view