An image forming apparatus configured to operate in a first power state and a second power state in which power consumption is smaller than power consumption in the first power state, the image forming apparatus comprising: an operation means configured to receive a user operation; a detection means configured to detect an object present in front of the image forming apparatus; and a power-supply control means configured to shift the state of the image forming apparatus from the second power state to the first power state, when the detection means detects an object present in front of the image forming apparatus, wherein when the image forming apparatus is in the first power state: the power-supply control means is configured to shift the state of the image forming apparatus from the first power state to the second power state based on a lapse of a predetermined time with no object detected by the detection means, in a case where a job has not been executed and the operation means received a user operation in a certain period after the image forming apparatus returned to the first power state and before the detection means detects no object present in front of the image forming apparatus; the power-supply control means is configured to shift the state of the image forming apparatus from the first power state to the second power state without waiting for the lapse of the predetermined time, in a case where a job has not been executed and the operation means did not receive a user operation in the certain period after the image forming apparatus returned to the first power state and before the detection means detect no object present in front of the image forming apparatus; and the power-supply control means is configured to shift the state of the image forming apparatus from the first power state to the second power state without waiting for the lapse of the predetermined time, in a case where the detection means has not detected an object and the job has been executed. an operation means configured to receive a user operation; a detection means configured to detect an object present in front of the image forming apparatus; and a power-supply control means configured to shift the state of the image forming apparatus from the second power state to the first power state, when the detection means detects an object present in front of the image forming apparatus, wherein when the image forming apparatus is in the first power state: the power-supply control means is configured to shift the state of the image forming apparatus from the first power state to the second power state based on a lapse of a predetermined time with no object detected by the detection means, in a case where a job has not been executed and the operation means received a user operation in a certain period after the image forming apparatus returned to the first power state and before the detection means detects no object present in front of the image forming apparatus; the power-supply control means is configured to shift the state of the image forming apparatus from the first power state to the second power state without waiting for the lapse of the predetermined time, in a case where a job has not been executed and the operation means did not receive a user operation in the certain period after the image forming apparatus returned to the first power state and before the detection means detect no object present in front of the image forming apparatus; and the power-supply control means is configured to shift the state of the image forming apparatus from the first power state to the second power state without waiting for the lapse of the predetermined time, in a case where the detection means has not detected an object and the job has been executed. the power-supply control means is configured to shift the state of the image forming apparatus from the first power state to the second power state based on a lapse of a predetermined time with no object detected by the detection means, in a case where a job has not been executed and the operation means received a user operation in a certain period after the image forming apparatus returned to the first power state and before the detection means detects no object present in front of the image forming apparatus; the power-supply control means is configured to shift the state of the image forming apparatus from the first power state to the second power state without waiting for the lapse of the predetermined time, in a case where a job has not been executed and the operation means did not receive a user operation in the certain period after the image forming apparatus returned to the first power state and before the detection means detect no object present in front of the image forming apparatus; and the power-supply control means is configured to shift the state of the image forming apparatus from the first power state to the second power state without waiting for the lapse of the predetermined time, in a case where the detection means has not detected an object and the job has been executed.