I also watched the FA Cup Final in the afternoon with Mauser, L and Clare, because Mauser and L had bought lots of sweets/snacks and some Dr. Pepper to have while we watched it.
In the evening I had a problem when uploading some images to my photo website. I had images with filenames like
903-Ilex-aquifolium-'Silver-Queen'-European-Holly-Flower.jpg
And I was trying to resize these images from the PHP script with a shell call to ImageMagick. In PHP I was using escapeshellcmd
to escape the filename, but looking at the PHP manual, escapeshellcmd
leaves paired quotation marks alone (i.e. it doesn't escape them). It seems that the shell just drops paired quotation marks, and so ImageMagick would try and resize903-Ilex-aquifolium-Silver-Queen-European-Holly-Flower.jpg
which didn't exist.There are two possible solutions I can think of. One would be running a
preg_replace
after running escapeshellcmd
, to find any unescaped quote characters, and escape them. The other solution (which I chose) is to use escapeshellarg
instead of escapeshellcmd
.The only problem with using
escapeshellarg
instead of escapeshellcmd
is that escapeshellarg
wraps your string in quote tags. So while before I was escaping my filename once using escapeshellcmd
and storing this in a variable, then using the variable to create different sized images with different filepaths but the same filename, I now had to use escapeshellarg
on each full filepath. e.g.Before I could do
$filename = escapeshellcmd($filename);
createLarge('./large/'.$filename);
createMedium('./medium/'.$filename);
createSmall('./small/'.$filename);
But now I had to do
createLarge(escapeshellarg('./large/'.$filename));
createMedium(escapeshellarg('./medium/'.$filename));
createSmall(escapeshellarg('./small/'.$filename));
I also found a better way of removing the thumbnail from the image - instead of just removing the thumbnail, remove all of IFD1. Also in that thread it mentions PreviewImage, so I changed my command to remove that as well.
Food
Breakfast: Strawberry Toast Sandwich; Cup o' Tea.
Lunch: Mature Cheddar Cheese with Red Onion, Raddish, Cherry Tomatoes, and Iceberg Lettuce Sandwich; Satsuma; Slice of Home-made Swiss Roll; Caramel Wacko (Michael Jackson endorsed Caramel Rocky substitute); Cup o' Tea.
Dinner: 2x Corn Beef Fritters; Baked Beans; Chips; Grated Mature Cheddar Cheese; Brown Sauce. Pudding was a Caramel Milk Jelly. Coffee.
No comments:
Post a Comment