Skip to content

Having data passed from PHP, how can we handle the file? #65

@realtebo

Description

@realtebo

I've this snippet reading a png

   <?php
        $file_name = './ReactNative-snapshot-image6513693026486043647.png';
        $image_file_content = base64_encode(file_get_contents( $file_name ));

        $image_size = getimagesize( $file_name );
    ?>

I need to convert the png to a Uint8ClampedArray (to decode a QRCode client-side, long story)

Is there a way using your lib to get file content from a base64 string?

For instance, I am doing a similar thing using jpeg-js

    const jpegData = Buffer.from("<?php echo $image_file_content ?>", 'base64');
    const rawImageData = jpeg.decode(jpegData);
    const clamped_array = Uint8ClampedArray.from(rawImageData.data);
    const decodedGreenpass = window.jsQR(
          clamped_array,
         <?php echo $image_size[0]; ?>,
         <?php echo $image_size[1]; ?>
    );

I need to obtain in some way pngData or a Uint8ClampedArray

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions