Skip to content

local image starting with file:// won't work #218

Closed

Description

@pierroo

Describe the bug
I recently upgraded RN to 0.73, so I had to upgrade this library to 1.2.6
But since then, markText with src image no longer works

I now get the error "please set image!"
when the image is indeed set.

Devlopment environment(please complete the following information):

  • react-native: 0.73.3
  • react-native-image-marker : 1.2.6

Smartphone (please complete the following information):

  • Device: emulator & device
  • OS: android (for now)

Additional context
Important to note: the image is coming from a viewshot capture, but still, that local file path used to work in previous versions.

EDIT: actually even with a local image using require('pathToImage') I still get the same error :/

Activity

  1. JimmyDaddy commented on Feb 9, 2024

    @JimmyDaddy
    Owner

    Hello @pierroo, can you provide me a sample code about how you use the library?

  2. pierroo commented on Feb 9, 2024

    @pierroo
    Author

    Of course @JimmyDaddy , here it is:

    viewShotRefs?.current
            .capture()
            .then(async uri => {
              console.log('view shot: ', uri);
              ImageMarker.markText({
                src: uri, // file://
                text: 'blablabla'
                  }`,
                scale: 1,
                quality: 100,
                saveFormat: 'base64',
                position: 'bottomRight',
                color: '#ffffff',
                fontSize: 36,
                shadowStyle: {
                  dx: 1,
                  dy: 1,
                  radius: 10,
                  color: '#000000',
                },
              })
                .then(res => {
                  goShare(res);
                })
                .catch(err => {
                  console.log('error marking img: ', err);
                });
            })
            .catch(e => {
              console.log('could not capture full canvas: ', e);
            });
    
  3. JimmyDaddy commented on Feb 9, 2024

    @JimmyDaddy
    Owner

    @pierroo the API has been changed in v1.x.x, you should modify you code like below

      viewShotRefs?.current
        .capture()
        .then(async (uri) => {
          console.log('view shot: ', uri);
          try {
            const markRes = await ImageMarker.markText({
              backgroundImage: {
                src: uri,
                scale: 1,
              },
              watermarkTexts: [
                {
                  text: 'blablabla',
                  position: {
                    position: Position.bottomRight,
                  },
                  style: {
                    color: '#ffffff',
                    fontSize: 36,
                    shadowStyle: {
                      dx: 1,
                      dy: 1,
                      radius: 10,
                      color: '#000000',
                    },
                  },
                },
              ],
              scale: 1,
              quality: 100,
              saveFormat: ImageFormat.base64,
            });
            goShare(markRes);
          } catch (err) {
            console.log('error marking img: ', err);
          }
        })
        .catch((e) => {
          console.log('could not capture full canvas: ', e);
        });

    document here

  4. Repository owner locked and limited conversation to collaborators on Feb 9, 2024
  5. converted this issue into a discussion #219 on Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions