protected function createResampledAsset($filename) {
        $fullpath = Director::baseFolder() . '/' . $filename;
        $asset = ContentServiceAsset::get()->filter('Filename', $filename)->first();

		if(!$asset) {
            $asset = new ContentServiceAsset();
        }

        $this->service = singleton('ContentService');


        $asset->Filename = $filename;
        $asset->SourceID = $this->ID;
        $asset->ParentID = $this->ParentID;
        $mtime = time();

        $writer = $this->service->getWriterFor($asset, 'FilePointer', $this->targetStore());
        if ($writer) {
            if (file_exists($fullpath)) {
                // likely that cached image never got built correctly.
                $name = \Controller::join_links(dirname($filename), $mtime, basename($filename));
                $writer->write(fopen($fullpath, 'r'), $name);

                $asset->FilePointer = $writer->getContentId();
                $asset->write();

                $reader = $writer->getReader();
                if ($reader && $reader->exists()) {
                    singleton('ContentDeliveryService')->removeLocalFile($fullpath);
                }
            } else {
                $asset = null;
            }
        } else {
            $asset = null;
        }

        return $asset;
    }