AWS Elastic Transcoder watermarks - php

I'm trying to add a watermark to all my videos being processed through Amazon elastic transcoder but I can't get it to working.
I created the preset with one watermark set(BottomRight) as in docs.
Here's my PHP source
$output = array(
'Key' => $folderNameOut,
'PresetId' => '139450346',
'ThumbnailPattern' => 'thumbs/filename-{count}',
'Watermarks' => array(
'InputKey' => 'watermark/watermark.png',
'PresetWatermarkId' => 'BottomRight'
));
I tried putting the watermark image in both thumbs and video buckets, even HTTP URL but doesn't work.
Can someone help me with this?

There is a missing array inside the watermarks array
$output = array(
'Key' => $folderNameOut,
'PresetId' => '139450346',
'ThumbnailPattern' => 'thumbs/filename-{count}',
'Watermarks' => array(
array(
'InputKey' => 'watermark/watermark.png',
'PresetWatermarkId' => 'BottomRight'
)
));

Related

How to extend typo3 image editor to add another format 16:11?

How to add more options in "Image manipulation" editor in typo3 FAL Image
Please find below Image for detail description
Createn an extension and install it. Create the file Configuration/TCA/Overrides/sys_file_reference.php. This is where you can add ratios to the cropping tool:
$GLOBALS['TCA']['sys_file_reference']['columns']['crop']['config'] = array(
'type' => 'imageManipulation',
'allowedExtensions' => 'jpg',
'ratios' => array(
'1.7777777777777777' => '16:9',
'1.3333333333333333' => '4:3',
'0.71428571428571' => '5:7',
'1' => '1:1',
'NaN' => 'Free',
),
);

Retina iconLink with Google Drive API

I'm an getting a list of files in a folder. The response contains a iconLink for every file returned. This icon is 16x16 pixels.
Does anyone know a way to retrieve a retina image? Or another way to retrieve a bigger icon image?
https://developers.google.com/drive/v2/reference/files
top: Google Drive UI
bottom: Google Drive API integration
The good news is although not officailly documented driver does have 2x resolution icons. The bad news is they have inconsistent file names; for example the icon you linked in the comments has a 32px version availabel here: ssl.gstatic.com/docs/doclist/images/mediatype/icon_3_pdf_x32.png
Now here is my soltion, it's not perfect but it will do the job for a while:
function getIcons($file_type)
{
$icons = [
'pdf' => [
'icon' => 'icon_12_pdf_list.png',
'retina' => 'icon_3_pdf_x32.png'
],
'document' => [
'icon' => 'icon_1_document_x16.png',
'retina' => 'icon_1_document_x32.png'
],
'image' => [
'icon' => 'con_1_image_x16.png',
'retina' => 'icon_1_image_x32.png'
],
'word' => [
'icon' => 'icon_1_word_x16.png',
'retina' => 'icon_1_word_x32.png'
],
'text' => [
'icon' => 'icon_1_text_x16.png',
'retina' => 'icon_1_text_x32.png'
],
'spreadsheet' => [
'icon' => 'icon_1_spreadsheet_x16.png',
'retina' => 'icon_1_spreadsheet_x32.png'
],
'form' => [
'icon' => 'icon_2_form_x16.png',
'retina' => 'icon_2_form_x32.png'
],
'audio' => [
'icon' => 'icon_1_audio_x16.png',
'retina' => 'icon_1_audio_x32.png'
]
];
return isset($icons[$file_type]) ? $icons[$file_type] : $icons['text'];
}
The reasion I say it will work for a while is that I'm asuming the _3_ in pdf icon file name for instance is the version number. So if Google updates it's icons again in the future this solution may brake.
I'm using drive rest api and what i observed was that iconLink attribute had a definite pattern.
"https://drive-thirdparty.googleusercontent.com/" + size + mimetype
By default size is 16. So, before adding your icon to Image, use this:
String iconLink = (String) jsonObject.get("iconLink");
iconLink=iconLink.replace("16","128");
check out these both links:
https://drive-thirdparty.googleusercontent.com/128/type/application/pdf
https://drive-thirdparty.googleusercontent.com/16/type/application/pdf
Looks like images with x128 also added/present for various versions:
Ver. 1
Ver. 2
Ver. 3
Better to replace the x16 from the fetched iconLink and replace it with x128.

Amazon AWS putBucketLogging parameters in PHP

I am writing script that connects to amazon S3 storage. The script is supposed to create 2 buckets:
Bucket is for data
Bucket is for logs
I successfully created both buckets but I can't set up logging. Below is shown code I use for enabling bucket logging
$result = $client->putBucketLogging(array(
'Bucket' => $bucket,
'LoggingEnabled' => array(
'TargetBucket' => $bucket . '-LOG',
'TargetGrants'=>array(
'Grantee'=>array(
'DisplayName'=>'user.name',
'Type'=>'CanonicalUser'
),
),
'TargetPrefix' => 'LOG-',
),
));
In amazon AWS API for PHP version 2 is written that Bucket, LoggingEnabled and Type are mandatory. But the documentation does not say how to exactly implement there parameters.
Could you please help me with structure of config array for putBucketLogging method?
You can also use the service's API documents as a reference, which sometimes contain more details about how to specifically structure some of the data types for requests. The S3 API docs for PUT Bucket Logging have more details about how to specify the grantee.
Also, you should not use capital letters in bucket names (See Rules for Bucket Naming).
After searching in manuals the php array for method putBucketLogging is
$result = $client->putBucketLogging(array(
'Bucket' => $bucket,
'LoggingEnabled' => array(
'TargetBucket' => $bucket . '-log',
'TargetGrants' => array(
'Grant' => array(
'Grantee' => array(
'Type' => 'AmazonCustomerByEmail',
'EmailAddress' => 'email#email.com',
),
'Permission' => 'FULL_CONTROL',
),
),
'TargetPrefix' => 'log-',
),
));
However enabling logging fails with exception that tells me I have to set permissions on log bucket...

Post Photoset using Tumblr API PHP

I am trying to upload multiple photos into a photoset post to Tumblr. I am using PHP to connect to Tumblr and authenticate. I can post individual photos and video but can't seem to figure out photosets. There are other posts on Stack that help other languages except for PHP.
I have a directory of photos. I get the contents of those file and put them into an array using scandir. But when I try to post that array to Tumblr, it doesn't work.
$scanned_directory = array_diff(scandir($directory), array('..', '.'));
$connection->post("blog/$hostname/post", array('type' => 'photo',
'state' => $dest, 'link' => $sourceurl, 'source' => $sourceurl,
'caption' => $caption, 'tags' => $tags , 'data' =>
$scanned_directory));
What am I doing wrong?
Thanks for the help!
I think you should iterate the $scanned_directory variable and make sure you don't submit the just the path and filename to the Tumblr API, but the actual contents of your image file with file_get_contents(), a working example would look probably something like this:
foreach($scanned_directory as $filename){
$data[] = file_get_contents($directory.'/'.$filename);
}
$connection->post("blog/$hostname/post", array('type' => 'photo', 'state' => $dest, 'link' => $sourceurl, 'source' => $sourceurl, 'caption' => $caption, 'tags' => $tags , 'data' => $data));
That should likely do the trick, just make sure the $directory variable is actually an absolute path to your image directory (e.g. '/var/www/myhost.tld/public/images/photoset')

dynamic multi dimensional array creation in php

It may be simple question ,i am fresh to php,amazon
I want to do batch put to my SDB database. I download s php-sdb sdk from amazon and did it successfully.
$bPut = $sdb->batch_put_attributes($domineName, array(
'ItemOne' => array(
'Company' => 'a',
),
'ItemTwo' => array(
'Company' => 'a',
),
'ItemThree' => array(
'Company' => 'a',
)
), true, null);
its works fine.Now I want to make the array (the second parameter) dynamic ie I want to make itemOne,ItemTwo,ItemThree ... from SDB database , I did it using $key = implode($row['test']);
But I am fail to create a multidimensional array successfully>how can I do it.Please help
This:
$items['ItemOne']['Company'] = 'a';
$items['ItemTwo']['Company'] = 'a';
$items['ItemThree']['Company'] = 'a';
will give you this:
array(
'ItemOne' => array(
'Company' => 'a'
),
'ItemTwo' => array(
'Company' => 'a'
),
'ItemThree' => array(
'Company' => 'a'
)
);
And then you can use it like so:
$bPut = $sdb->batch_put_attributes($domineName, $items), true, null);
You can view and manage your uploaded data using SDB Explorer. In new upcoming version SDB Explorer will support bulk upload. You will be able to upload your large data in parallel threads.
http://www.sdbexplorer.com/

Categories