0

While I am selecting and compressing the image in angular7 the image gets compressing but the file shows the description but I want to get the base64 data only from that file? if is there way suggest me thanx in adv.

angular

for (var i = 0; i < newfiles.length; i++) {
    let images: Array<IImage> = [];
    const files = Array.from(element.target.files);
    ImageCompressService.filesArrayToCompressedImageSource(Array.from(element.target.files)).then(observableImages => {
        observableImages.subscribe((image) => {
            images.push(image);
        }, (error) => {
            console.log("Error while converting");
        }, () => {
            this.processedImages = images;
            arrayOfImagesFile = images;
            console.log("jvdff");

            this.showTitle = true;
        })
    })
};

in images there is showing files description that are --> image data URL which is base64 data and imageObjectUrl which is blob type Url but I want only imageDataUrl seperately

Ulysse BN
  • 10,116
  • 7
  • 54
  • 82
  • Will you add file data? @tejas-ingle ? – Hardik Masalawala Aug 14 '19 at 07:09
  • first i will take that base64 data and after compressing that i am converting into file and sending to the server but from that file i want base64 string . – Tejas Ingle Aug 14 '19 at 07:11
  • @HardikMasalawala – Tejas Ingle Aug 14 '19 at 07:22
  • Are you able to convert that file data into base64? if yes then you can convert file data into bas64 using JavaScript and you will get string of base64 like this : https://stackoverflow.com/a/57272491/6923146 – Hardik Masalawala Aug 14 '19 at 07:24
  • What type of data you get after compression? String? if it's blob you can use [Convert blob to base64](https://stackoverflow.com/q/18650168/387194). If you have string then there is function `btoa` that create base64 but it will not be data URI. – jcubic Aug 14 '19 at 07:47

0 Answers0