Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

reactnative 使用react-native-image-marker库完成图片加水印的功能,如何设置水印宽高?

我使用了react-native-image-marker库完成图片加水印的功能,现在根据文档仅仅是通过设置markerScale去控制水印大小,但我上传的图片宽高大小都不一,现在会出现水印偏移或者水印未能完全覆盖图片的情况。react-native-image-marker

getWaterImage = params => {
        const { img, setStatus, setName } = params;
        ImageMarker.markImage({
            src: img,
            markerSrc: require('./images/water_img.png'),
            position: 'center', // topLeft, topCenter,topRight, bottomLeft, bottomCenter , bottomRight, center
            maxSize: 100,
            scale: 1,
            markerScale: 4,
            saveFormat: 'base64',
            quality: 100
        })
            .then(path => {
                this.setState({
                    [setName]: path,
                    ...setStatus
                });
            })
            .catch(err => {
                console.log(err, 'err');
                this.setState({
                    loading: false,
                    err
                });
            });
    };
 <ImageBackground
                                    style={styles.cameraImg}
                                    source={{ uri: handImgPath }}
                                    resizeMode={'stretch'}
                                >
                                    {handImgStatus !== 'normal' && handImgStatus !== 'success' ? (
                                        <View style={styles.cameraMask}>
                                            <Text style={styles.cameraTips}>上传中</Text>
                                        </View>
                                    ) : null}
                                </ImageBackground>

我希望水印能刚好覆盖在图片上,我使用的是base64的图片,请问有使用过这个库的小伙伴吗?我想知道你们有没有好的解决方案,好让我能控制水印的展示情况。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...