I am attempting to resize an array of images, but i keep getting the same image returned multiple times.
I’m wondering if this could be by design in the Native Module? Maybe some constant is being set and is preventing iteration? (not sure if that would even be possible).
Or is it something wrong with my code design?
Here’s just a few of the methods i’ve tried without success -
(Expo v27)
Method 1:
_start = async (images) => {
let results = images.map(async (image) => {
var manipResult = await ImageManipulator.manipulate(
image.uri,
[{ resize: { height: 300 }}],
{ format: 'jpeg', compress: 1}
)
console.log(manipResult) // same photo, different URIs
return manipResult
});
Promise.all(results).then((completed) => {
console.log(completed) // same photo, different URIs
});
}
Method 2:
// helper method constant:
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
_start = async (images) => {
let resized = []
await asyncForEach(images, async (images) => {
let manipResult = await ImageManipulator.manipulate(
images.uri,
[{ resize: { height: 300 }}],
{ format: 'jpeg', compress: 1}
)
resized.push(manipResult)
})
console.log(resized); // same photo, different URIs
}
Method 3:
_start = async (images) => {
for (var asset of images){
console.log(asset.uri) // Different photos
let manipResult = await ImageManipulator.manipulate(
asset.uri,
[{ resize: { height: 300 }}],
{ format: 'jpeg', compress: 1}
)
console.log(await manipResult); // same photo, different URIs
}
}