JimmyDaddy / react-native-image-marker

🙈Adding text or icon watermark to your image using React Native👀👀
https://jimmydaddy.github.io/react-native-image-marker/
MIT License
316 stars 93 forks source link

Error adding image icon watermark: [Error: please set image!] #220

Closed hrituraj-hr closed 7 months ago

hrituraj-hr commented 7 months ago

Describe the bug I want to add icon in an image.For that I have provided two paths The paths are like this Main URL https://firebasestorage.google................eaa Icon URL file:///storage/emulated/0/Android/data/...........ce1fbeb367ce.jpg

This is the code

import ImageMarker from 'react-native-image-marker';

const EditPic = async (imageUri, iconImageUrl, iconOpacity = 1, position) => {

  try {
    const markedImage = await addImageIconWatermark(imageUri, iconImageUrl, iconOpacity, position);
    return markedImage;
  } catch (error) {
    console.error('Error editing picture:', error);
    return null;
  }
};

const addImageIconWatermark = async (imageUri, iconImageUrl, iconOpacity = 1, position) => {
    console.log("Main URL ", imageUri);
    console.log("Icon URL ", iconImageUrl);
    if (!imageUri || !iconImageUrl) {
    return console.error('Please provide image and icon URL');
  }

  const options = {
    backgroundImage: {
        src: mainurl,
        scale: 1,
        rotate: 0,
        alpha: 0.5,
      },

      watermarkImages: [
        {
          src: iconImageUrl,
          scale: 0.5,
          rotate: 45,
          alpha: 0.5,
          position: {
            X: 10,
            Y: 10,
          },
        },

      ],
     };

     await ImageMarker.markImage(options);

};

export default EditPic;

To Reproduce A image uri having the image with icon.

Expected behavior It should return a image uri having the image with icon.

Devlopment environment(please complete the following information):

Smartphone (please complete the following information):