Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to merge collection #1189

Open
santosh-kumar-kaushal opened this issue May 18, 2022 · 21 comments
Open

Is it possible to merge collection #1189

santosh-kumar-kaushal opened this issue May 18, 2022 · 21 comments

Comments

@santosh-kumar-kaushal
Copy link

1st Base character and 30 Layers generate = 1000 NFT
2nd Base character and 25 Layers generate = 1000 NFT
3nd Base character and 35 Layers generate = 1000 NFT

Now we have 3000, can we jumble the numbers in the collection for images and JSON files?

Need help! Thanks in advance.

@santosh-kumar-kaushal
Copy link
Author

@bolshoytoster Please check this.

@bolshoytoster
Copy link

@santosh-kumar-kaushal you could copy the images and individual metadata files from 2 & 3 into the first collection, delete the _metadata.json file then run my utils/update_info.js to regenerate it. This will only work if your collections are 1-1000, 1001-2000 etc.

Is there any reason you can't just generate it as one collection?

@santosh-kumar-kaushal
Copy link
Author

@bolshoytoster I want to use different layers for a single base. base is different in size. please suggest the best way to do it. I want to shuffle them once the collection is created. 1000 with one base, 1001-2000 with another base and so on. now once I make a shuffle couple of them comes from 1001-2000 collection to 0-1000.

@santosh-kumar-kaushal
Copy link
Author

@bolshoytoster Please help

@bolshoytoster
Copy link

bolshoytoster commented May 19, 2022

@santosh-kumar-kaushal if you're fine with regenerating, you could use my fork which lets you set startEditionFrom the same way you set growEditionSizeTo. You could use this to do what I suggested earlier.

Once you have the single collection you could shuffle it with some really hacky untested code that probably doesn't work:

const basePath = process.cwd();
const fs = require("fs");

let array = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
array = JSON.parse(array);

let randomIndex;
array.forEach((currentElement, currentIndex) => {
  do {
    randomIndex = Math.floor(Math.random() * array.length) + 1;
  } while (currentElement.edition == randomIndex)

  fs.renameSync(
    `${basePath}/build/images/${randomIndex}.png`,
    `${basePath}/build/images/${randomIndex}.png.lol`
  )

  fs.renameSync(
    `${basePath}/build/images/${currentElement.edition}.png`,
    `${basePath}/build/images/${randomIndex}.png`
  )

  fs.renameSync(
    `${basePath}/build/images/${randomIndex}.png.lol`,
    `${basePath}/build/images/${currentElement.edition}.png`
  )

  temp = array[array.findIndex(k => k.edition == randomIndex)];

  array[array.findIndex(k => k.edition == randomIndex)] = array[array.findIndex(k => k.edition == currentElement.edition)];
  array[array.findIndex(k => k.edition == currentElement.edition)] = temp;
});

fs.writeFileSync(
  `${basePath}/build/json/_metadata.json`,
  JSON.stringify(array, null, 2)
);

Then run node utils/update_info.js.

@santosh-kumar-kaushal
Copy link
Author

@bolshoytoster so you mean the single collection will be shuffled including images and JSON files

Let's say 2.png is now 120.png with its JSON

@bolshoytoster
Copy link

@santosh-kumar-kaushal it should be (if the code works).

@santosh-kumar-kaushal
Copy link
Author

santosh-kumar-kaushal commented May 19, 2022

@bolshoytoster Let me try and will come back soon, Thanks a lot for helping me out :) I have another short question is there a possibility if we can combine layers GIF + PNG = GIF

@bolshoytoster
Copy link

@santosh-kumar-kaushal does this help?

@santosh-kumar-kaushal
Copy link
Author

@santosh-kumar-kaushal does this help?

No actually, I have GIFs and PNGs, this repo creates gifs out of PNGs

@bolshoytoster
Copy link

@santosh-kumar-kaushal well you'll have to split the gifs into individual frames then.

@santosh-kumar-kaushal
Copy link
Author

@santosh-kumar-kaushal well you'll have to split the gifs into individual frames then.

I'm trying to merge the collection, will try this once this is successful, will keep you posted.

@santosh-kumar-kaushal
Copy link
Author

@santosh-kumar-kaushal if you're fine with regenerating, you could use my fork which lets you set startEditionFrom the same way you set growEditionSizeTo. You could use this to do what I suggested earlier.

Once you have the single collection you could shuffle it with some really hacky untested code that probably doesn't work:

const basePath = process.cwd();
const fs = require("fs");

let array = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
array = JSON.parse(array);

let randomIndex;
array.forEach((currentElement, currentIndex) => {
  do {
    randomIndex = Math.floor(Math.random() * array.length) + 1;
  } while (currentElement.edition == randomIndex)

  fs.renameSync(
    `${basePath}/build/images/${randomIndex}.png`,
    `${basePath}/build/images/${randomIndex}.png.lol`
  )

  fs.renameSync(
    `${basePath}/build/images/${currentElement.edition}.png`,
    `${basePath}/build/images/${randomIndex}.png`
  )

  fs.renameSync(
    `${basePath}/build/images/${randomIndex}.png.lol`,
    `${basePath}/build/images/${currentElement.edition}.png`
  )

  temp = array[array.findIndex(k => k.edition == randomIndex)];

  array[array.findIndex(k => k.edition == randomIndex)] = array[array.findIndex(k => k.edition == currentElement.edition)];
  array[array.findIndex(k => k.edition == currentElement.edition)] = temp;
});

fs.writeFileSync(
  `${basePath}/build/json/_metadata.json`,
  JSON.stringify(array, null, 2)
);

Then run node utils/update_info.js.

@bolshoytoster This is shuffling the images in the image folder but not shuffling the JSON files in the JSON folder. Please help.

@bolshoytoster
Copy link

@santosh-kumar-kaushal did you run node utils/update_info.js afterwards?

@santosh-kumar-kaushal
Copy link
Author

@santosh-kumar-kaushal did you run node utils/update_info.js afterwards?

Yes, I did but Json files are not shuffling, it stays as it is.

@bolshoytoster
Copy link

@santosh-kumar-kaushal what about this:

const basePath = process.cwd();
const fs = require("fs");

let array = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
array = JSON.parse(array);

let randomIndex;
array.forEach((currentElement, currentIndex) => {
  do {
    randomIndex = Math.floor(Math.random() * array.length) + 1;
  } while (currentElement.edition == randomIndex)

  fs.renameSync(
    `${basePath}/build/images/${randomIndex}.png`,
    `${basePath}/build/images/${randomIndex}.png.lol`
  )

  fs.renameSync(
    `${basePath}/build/images/${currentElement.edition}.png`,
    `${basePath}/build/images/${randomIndex}.png`
  )

  fs.renameSync(
    `${basePath}/build/images/${randomIndex}.png.lol`,
    `${basePath}/build/images/${currentElement.edition}.png`
  )

  temp = array[array.findIndex(k => k.edition == randomIndex)].edition;

  array[array.findIndex(k => k.edition == randomIndex)].edition = array[array.findIndex(k => k.edition == currentElement.edition)].edition;
  array[array.findIndex(k => k.edition == currentElement.edition)].edition = temp;
});

fs.writeFileSync(
  `${basePath}/build/json/_metadata.json`,
  JSON.stringify(array, null, 2)
);

For me it doesn't look like it's even shuffling images.

@santosh-kumar-kaushal
Copy link
Author

_metadata.json

I can see shuffling in _metadata.json file but it is not matching with the image layers, Looks like _metadata.json is shuffled with other random values.

@santosh-kumar-kaushal
Copy link
Author

@santosh-kumar-kaushal what about this:

const basePath = process.cwd();
const fs = require("fs");

let array = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
array = JSON.parse(array);

let randomIndex;
array.forEach((currentElement, currentIndex) => {
  do {
    randomIndex = Math.floor(Math.random() * array.length) + 1;
  } while (currentElement.edition == randomIndex)

  fs.renameSync(
    `${basePath}/build/images/${randomIndex}.png`,
    `${basePath}/build/images/${randomIndex}.png.lol`
  )

  fs.renameSync(
    `${basePath}/build/images/${currentElement.edition}.png`,
    `${basePath}/build/images/${randomIndex}.png`
  )

  fs.renameSync(
    `${basePath}/build/images/${randomIndex}.png.lol`,
    `${basePath}/build/images/${currentElement.edition}.png`
  )

  temp = array[array.findIndex(k => k.edition == randomIndex)].edition;

  array[array.findIndex(k => k.edition == randomIndex)].edition = array[array.findIndex(k => k.edition == currentElement.edition)].edition;
  array[array.findIndex(k => k.edition == currentElement.edition)].edition = temp;
});

fs.writeFileSync(
  `${basePath}/build/json/_metadata.json`,
  JSON.stringify(array, null, 2)
);

For me it doesn't look like it's even shuffling images.

I have created shuffle.js in the utils package and pasted this piece of code in it. Running with the command line shuffles individual images and metadata.json but JSON shuffling is not matching with shuffled image layers.

node utils/shuffle.js

@santosh-kumar-kaushal
Copy link
Author

@bolshoytoster did you find anything? Please help.

@bolshoytoster
Copy link

@santosh-kumar-kaushal no, sorry, you could try fixing it yourself though.

@santosh-kumar-kaushal
Copy link
Author

santosh-kumar-kaushal commented May 21, 2022

@santosh-kumar-kaushal no, sorry, you could try fixing it yourself though.

I don't have exposure to python but I tried it. unfortunately, it didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants