Created
July 25, 2019 16:58
-
-
Save aj07mm/b96495f9b9ba29044c35d507cd0d41de to your computer and use it in GitHub Desktop.
Revisions
-
aj07mm created this gist
Jul 25, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ def get_image_file(name='test.png', ext='png', size=(50, 50), color=(256, 0, 0)): from StringIO import StringIO from PIL import Image from django.core.files import File file_obj = StringIO() file_obj.write('') image = Image.new("RGBA", size=size, color=color) image.save(file_obj, ext) file_obj.seek(0) return File(file_obj, name=name)