Jump to content

I have a php script that runs imagecreate(), but I need the size limit removed.

Poet129
Go to solution Solved by Poet129,
2 hours ago, Poet129 said:

I've found I do have the 64 bit version so this is just the library then.

Just ended up using a different library.

I have a made a php script that runs imagecreate(), I need a way to remove the int_max error. Here is an example:

 

Screenshot from 2020-12-30 18-33-22.png

Link to comment
Share on other sites

Link to post
Share on other sites

Errors like that aren't something that you can just turn off... you need to figure out what's wrong with your code. I'd try to help you with that but you didn't even post it.

 

Just looking at the error though - that seems like a really large image, what are you trying to do that needs it? Perhaps an image of that size simply isn't supported by the library you're using...

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Poet129 said:

I need a way to remove the int_max error.

You need to use a 64-bit PHP instead of 32-bit. The 32-bit build has a limit of 2147483647 for an integer-value.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Sauron said:

Errors like that aren't something that you can just turn off... you need to figure out what's wrong with your code. I'd try to help you with that but you didn't even post it.

 

Just looking at the error though - that seems like a really large image, what are you trying to do that needs it? Perhaps an image of that size simply isn't supported by the library you're using...

The issue is that there is a set max so that if you put this on a website there is limit so your website doesn't crash, but as you can see I'm trying to run this locally.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, WereCatf said:

You need to use a 64-bit PHP instead of 32-bit. The 32-bit build has a limit of 2147483647 for an integer-value.

I'm running ubuntu how do I switch versions.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, Poet129 said:

The issue is that there is a set max so that if you put this on a website there is limit so your website doesn't crash, but as you can see I'm trying to run this locally.

How do you know this? What @WereCatfsuggested seems like a much likelier cause. But even then, the core of the issue is that you're trying to write a number larger than the maximum supported by either the library or the interpreter, which should be addressed with a size check in your code.

 

Also I would hope this isn't an attempt to do what you posted about last time where everyone in the threat suggested a better solution than making a giant image.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

18 minutes ago, Sauron said:

How do you know this? What @WereCatfsuggested seems like a much likelier cause. But even then, the core of the issue is that you're trying to write a number larger than the maximum supported by either the library or the interpreter, which should be addressed with a size check in your code.

Okay but how do I know whether I have the 32 bit or 64 bit version of php?

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, Poet129 said:

Okay but how do I know whether I have the 32 bit or 64 bit version of php?

I've found I do have the 64 bit version so this is just the library then.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Poet129 said:

I've found I do have the 64 bit version so this is just the library then.

Just ended up using a different library.

Link to comment
Share on other sites

Link to post
Share on other sites

imagecreate has to allocate enough memory to hold all the pixel information, so if you're trying to make a 57928 x 57925 picture,  you'll have  3,355,479,400  pixels.  By default, imagecreate uses either 24bit or 32 bit for each pixel (3 or 4 bytes), so the code (probably mine, as I recognize the text output) tries to allocate 10,066,438,200 bytes  or 13,421,917,600 bytes

 

On 32 bit PHP, INT_MAX is int(2147483647) , which is 231-1 , because the 32nd bit is used for sign.

 

You should try to keep the image resolutions below 16k x 16k  (214 x 214) which is enough to give you 268,435,456 bits or 33,554,432 bytes  or 32 MB.

It's quite simple ... if you have big files, just split the file into multiple chunks of let's say 1-4-8-16 MB and make pictures of each of those chunks.

 

Also, you would have to go in php.ini  (configuration of php to allow) to increase the maximum memory a script is allowed to use (I think the parameter is memory_limit  or some parameter like that). If that setting is too low, your script will be killed when it uses too much memory. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×