def __getitem__(self, key):
try:<EOL><INDENT>width, height = [int(i) for i in key.split('<STR_LIT:x>')]<EOL><DEDENT>except (KeyError, ValueError):<EOL><INDENT>raise MalformedSizedImageKey(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % self.__class__.__name__<EOL>)<EOL><DEDENT>if not self.path_to_image and getattr(<EOL>settings, '<STR_LIT>', False<EOL>):<EOL><INDENT>resized_url = "<STR_LIT>" % (width, height)<EOL>resized_storage_path = resized_url<EOL><DEDENT>else:<EOL><INDENT>resized_storage_path = get_resized_path(<EOL>path_to_image=self.path_to_image,<EOL>width=width,<EOL>height=height,<EOL>filename_key=self.get_filename_key(),<EOL>storage=self.storage<EOL>)<EOL>try:<EOL><INDENT>resized_url = self.storage.url(resized_storage_path)<EOL><DEDENT>except Exception:<EOL><INDENT>resized_url = None<EOL><DEDENT>if self.create_on_demand is True:<EOL><INDENT>if cache.get(resized_url) and resized_url is not None:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if resized_storage_path and not self.storage.exists(<EOL>resized_storage_path<EOL>):<EOL><INDENT>self.create_resized_image(<EOL>path_to_image=self.path_to_image,<EOL>save_path_on_storage=resized_storage_path,<EOL>width=width,<EOL>height=height<EOL>)<EOL>resized_url = self.storage.url(resized_storage_path)<EOL><DEDENT>cache.set(resized_url, <NUM_LIT:1>, VERSATILEIMAGEFIELD_CACHE_LENGTH)<EOL><DEDENT><DEDENT><DEDENT>return SizedImageInstance(<EOL>name=resized_storage_path,<EOL>url=resized_url,<EOL>storage=self.storage<EOL>)<EOL>
Return a URL to an image sized according to key.

Arguments:
    * `key`: A string in the following format
             '[width-in-pixels]x[height-in-pixels]'
             Example: '400x400'