This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Proper exif rotation with PIL. Handles all the cases in https://github.com/recurser/exif-orientation-examples | |
from PIL import Image | |
image = Image.open(filename) | |
exif = image._getexif() | |
ORIENTATION = 274 | |
if exif is not None and ORIENTATION in exif: | |
orientation = exif[ORIENTATION] | |
method = {2: Image.FLIP_LEFT_RIGHT, 4: Image.FLIP_TOP_BOTTOM, 8: Image.ROTATE_90, 3: Image.ROTATE_180, 6: Image.ROTATE_270, 5: Image.TRANSPOSE, 7: Image.TRANSVERSE} | |
if orientation in method: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global $user; | |
$order = commerce_cart_order_load($user->uid); | |
commerce_cart_order_empty($order); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fields = array( | |
'field_my_fields' => 'field_my_new_field', | |
'field_other_field' => 'field_adam_west', | |
); | |
// Loop through each of the fields/tables with the old name and change them | |
foreach($fields as $field_name => $new_field_name) { | |
// First check that field_name exists | |
if(!db_table_exists('field_data_' . $field_name)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove any non-ASCII characters and convert known non-ASCII characters | |
* to their ASCII equivalents, if possible. | |
* | |
* @param string $string | |
* @return string $string | |
* @author Jay Williams <myd3.com> | |
* @license MIT License | |
* @link http://gist.github.com/119517 |