Test retina iPhone layouts in actual size using Dropbox.

Dropbox is great for testing retina iPhone mockups. Your design files are twice the size of the final product and it’s important to view them within the context of the device.

Create an alias/shortcut to your Dropbox testing folder on your desktop. Grab a screenshot the 960 x 640 design and throw it in the Dropbox alias/shortcut folder. Open it it up through Dropbox on your iPhone and view in @2x retina glory.

I find the workflow between screenshots and the alias/shortcut folder quick enough to allow rapid iteration.

-Rick

5 Comments
Posted in Design, Mobile
Tagged , , ,

Resizing Django ImageField with Remote Storage

Recently I’ve been working on a project to move our photo experience to store images on Amazon’s S3 service instead of the local server, in hopes to gain performance and move away from handling the maintenance static files tend to have.

There are many examples online of saving directly to Amazon and not using Django’s Storage Backend, however these examples tend to not give the best overall experience, specially when the site is for a customer.  Why keep files on Amazon after a customer has deleted the relationship on your site?  Paying for the extra space is something I’m not looking to do.

Luckily during this search I learned about Django’s Storage API and loved the concept and found a great package called django-storage that already has implemented S3 support.  The documentation could use a bit of work, but isn’t too hard to get a handle of.

Now that I had the capability to save images to S3 I also wanted the possibility to resize said image and create a thumbnail.

The issue with this is that all examples I could find where in regards to either files saved on disk or stored in memory, neither of which was my case.

Below is example code that allows you to resize images using Django’s models.ImageField and PIL library.  Hopefully this saves someone some time as it took me a few hours to come up with a solution.


def _resize_image(self):
try:
import urllib2 as urllib
from PIL import Image
from cStringIO import StringIO
from django.core.files.uploadedfile import SimpleUploadedFile

'''Open original photo which we want to resize using PIL's Image object'''
img_file = urllib.urlopen(self.image.url)
im = StringIO(img_file.read())
resized_image = Image.open(im)

'''Convert to RGB if necessary'''
if resized_image.mode not in ('L', 'RGB'):
resized_image = resized_image.convert('RGB')

'''We use our PIL Image object to create the resized image, which already
has a thumbnail() convenicne method that constrains proportions.
Additionally, we use Image.ANTIALIAS to make the image look better.
Without antialiasing the image pattern artificats may reulst.'''
resized_image.thumbnail(self.image_max_resolution, Image.ANTIALIAS)

'''Save the resized image'''
temp_handle = StringIO()
resized_image.save(temp_handle, 'jpeg')
temp_handle.seek(0)

''' Save to the image field'''
suf = SimpleUploadedFile(os.path.split(self.image.name)[-1].split('.')[0],
temp_handle.read(), content_type='image/jpeg')
self.image.save('%s.jpg' % suf.name, suf, save=True)
except ImportError:
pass

4 Comments
Posted in Amazon S3, Django, PIL, Python
Tagged , , , ,

PIL Image from Url

Had some troubles finding what seemed to be such an easy Google search. Needed the capability to load an image based on a url. Here is my solution:

import urllib2 as urllib
from PIL import Image
from cStringIO import StringIO

img_file = urllib.urlopen(self.image.url)
im = StringIO(img_file.read())
resized_image = Image.open(im)
2 Comments
Posted in PIL, Python
Tagged , ,

Solving django-storage NotImplementedError with Amazon S3

Recently I started looking into Amazon’s S3 service to (hopefully) offer better performance on serving up static content for our customers.  Its a great service and ridiculously cheap.  The first client I am applying the S3 storage to is for Dylan Priest Photography, its critical that the images load as fast as possible as that is the main content of his site.  As our web-server is currently a bit overworked off loading the static content to S3 should help with overall performance.

Here at Hardly Code, we are mostly a Django shop.  I found a great plugin called django-storages that has multiple different type of storages.  The documentation is a little bit on the lite side and took a few hours to get the feel for it.  (It was my first time not using the default storage.)

I was applying this to our Album app but when trying to edit an album I kept getting (Creating a new album worked fine):
NotImplementedError: This backend doesn't support absolute paths.
The conflict was in the s3boto storage class the path method was not implemented. As per the Django documentation, for non local storage you should not implement this method.  The only way I found to solve this solution was to go ahead and implement this method in the django-storage code and modify storages.backends.s3boto and add the path method.


def url(self, name):
...
def path(self, name):
return None

A fairly easy fix and as far as I can tell it hasn’t created any issues with the modification. Not sure if this a bug with django, django-storage, or my implementation, but it took me long enough to figure out that I thought I would document it and hopefully save someone else some time.

Leave a comment
Posted in Amazon S3, Django
Tagged , , , , ,

Google Instant now with Preview

Awesome. I guess. Although Ask.com had this same feature in May of 2006. Ask.com even had a commercial about this
game-changer yet “Binoculars” didn’t really do much for the service.

I never found Binoculars useful. You could click an icon to see what a site looked like or you could click a link and be transported to the site. Continue reading

Leave a comment
Posted in Design, Search Engine Optimization

Finding Clients

The hardest part about starting a web development company hasn’t been doing the actual work, I am a confident developer who believes in his skills. However I missed the memo on having to also be a business man.

Below are a few ways I have found to help find clients and spread the word about your new business. Continue reading

Leave a comment
Posted in Business
Tagged , ,

The End Times Are Near

182626main image feature 872 ys 4 The End Times Are Near
Almost done! We’re cleaning up bugs and spell checking articles. We’ll make some sort of announcement very soon. Sorry about all the lorum ipsum and such. It wont be much longer.

2 Comments
Posted in Design