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.


    Share extension gets TWO images from the Photos.app when I select ONE image.

    Pythonista
    photos image
    2
    10
    2222
    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.
    • halloleooo
      halloleooo last edited by halloleooo

      My share extension image script works beautifully with selections from the the Files app, but with the Photos app, I have the problem that each image appears TWICE. For the following screenshot I had selected only ONE image, but the script gets TWO (identical) images delivered viaappex.get_images(image_type='ui'):

      Share extension with ONE image selected

      How can I avoid (or detect) this? I though this might happen because of HDR and normal image, however both images in the list returned from appex.get_images are of the same type _ui.Image.

      cvp 3 Replies Last reply Reply Quote 0
      • cvp
        cvp @halloleooo last edited by cvp

        @halloleooo do you have the same problem with pil image?

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @halloleooo last edited by cvp

          @halloleooo As your script process a join of two images, are you 100% sure it is not a bug?

          1 Reply Last reply Reply Quote 0
          • cvp
            cvp @halloleooo last edited by cvp

            @halloleooo this little script prints 1 for an unique photo and 2 if 2 photos shared

            import ui
            
            import appex
            
            class MyView(ui.View):
            	def __init__(self):
            		pass
            	def will_close(self):
            		appex.finish()
            		
            def main():
            	v = MyView()
            	v.present()
            	f = appex.get_images(image_type='ui')
            	print(len(f))
            		
            if __name__ == '__main__':
            	main()
            
            halloleooo 1 Reply Last reply Reply Quote 0
            • halloleooo
              halloleooo @cvp last edited by

              @cvp Well, I copied your code to Pythonista, hooked it up as Share Extension script - and when I run it from the Photos app with ONE image selected it prints 2!

              cvp 1 Reply Last reply Reply Quote 0
              • cvp
                cvp @halloleooo last edited by cvp

                @halloleooo HEIC gives 2 photos..., try this with your double photo, the 2nd one is HEIC

                Edit : if you want to avoid HEIC photos, go in Settings/Camera/Formats/Most Compatible

                import ui
                
                import appex
                
                class MyView(ui.View):
                	def __init__(self):
                		iv = ui.ImageView(name='iv')
                		iv.frame = self.bounds
                		self.add_subview(iv)
                	def will_close(self):
                		appex.finish()
                		
                def main():
                	v = MyView()
                	v.present()
                	f = appex.get_attachments()
                	n = ''
                	for fil in f:
                		i = fil.rfind('/')
                		n += fil[i+1:]+'  '
                	v.name = n
                	v['iv'].image = ui.Image.named(appex.get_attachments()[0])
                
                if __name__ == '__main__':
                	main()
                
                halloleooo 1 Reply Last reply Reply Quote 2
                • halloleooo
                  halloleooo @cvp last edited by

                  @cvp Yep HEIC must be the culprit. So HEIC photos are shared as HEIC and as JPG.

                  I don’t really understand your code yet, but I will try it. I assume you somehow detect whether the format is HEIC or not...

                  cvp 1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @halloleooo last edited by cvp

                    @halloleooo my code allowed to check the file name of your both attachments and thus see one was a jpg and the other an HEIC for the same photo. See the name (title) of the view.

                    halloleooo 1 Reply Last reply Reply Quote 0
                    • halloleooo
                      halloleooo @cvp last edited by

                      @cvp Aha! Yes, of course! I will use this!

                      Thanks heaps!

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

                        Just as a final follow-up: Using appex.get_attachments and Image.named works perfectly. Here my workflow:

                        1. I get the image file names via appex.get_attachments.
                        2. I weed out the paths for heic files which have a accompaning other image file.
                        3. Finally I load the remaining images manually via the Image.named method.

                        Thanks for your help, @cvp! :-)

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