title: How to get imagefield path in models?
body: <p>Happy new year and hello,i've got a problem with resizing images in django. I need to find out the way to get Imagefield path from model during loading images, how do i get? I wrote a func which changing upload path for Imagefield, i'd like to get an url to that file and past it in imagekit generator for resize.
  This is a func for changing upload path for Imagefield</p>
  <pre><code>def get_file_pathM(instance, filename):
  extension = filename.split('.')[-1]
  new_name = 'new_name'
  filename = &quot;%s.%s&quot; % (new_name, extension)
  print('geeeeeeeeeeeeeeeeet', os.path.join('photos/project_photo/%y/%m/%d'))
  date_now = date.today().strftime(&quot;%Y/%m/%d&quot;).split('/')
  path = 'photos/project_photo/{}/{}/{}'.format(date_now[0], date_now[1], date_now[2])
  return os.path.join(path, filename)
  </code></pre>
  <p>Here's my class of ImageSpec for resize</p>
  <pre><code>class Thumb(ImageSpec):
  processors = [ResizeToFill(100, 50)]
  format = 'JPEG'
  options = {'quality': 60}
  
  
  photo = models.ImageField(upload_to=get_file_pathM, verbose_name='Фото', blank=True, null=True)
  source_file = open('here should be an url to photo','rb')
  image_generator = Thumb(source=source_file)
  result = image_generator.generate()
  dest = open('media/photos/project_photo/2022/01/03/avtolider_new.jpg', 'wb')
  dest.write(result.read())
  dest.close()
  </code></pre>
  <p>And another question, it's said in imagekit documentary that's it's possible to use Imagefield as source in image_generator without using open, but it doesn't work somehow and shows an error, like Imagefiled can't open or close file.</p>