omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Resize image script not working after update

    Pythonista
    2
    2
    1280
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Gustaphzon
      Gustaphzon last edited by

      Hi.

      I borrowed a script from macdrifter.com and changed it little. It worked perfect, but after the update to 1.4 it runs without errors but don't resize the image. It only saves a new image in the same size as the original. Here is the code

      import Image
      import photos
      import console
      
      img = photos.pick_image()
      
      def customSize(img):
          w, h = img.size
          print 'w: ' + str(w)
          print 'h: '+ str(h)
          if w != 1000:
              wsize = 1000/float(w)
              print 'wsize: '+str(wsize)
              hsize = int(float(h)*float(wsize))
              print 'hsize: ' + str(hsize)
      
              img = img.resize((1000, hsize), Image.ANTIALIAS)
          return img
      
      image = customSize(img)
      print image.size
      image.show()
      
      saveit = photos.save_image(img)
      
      print "\n\n Bilden sparad"
      

      I'm a beginner and don't understand why this happens. Can someone please help me.

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        In the second last line, it should be photos.save_image(image) instead of photos.save_image(img).

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors