some refactor & fix image size compute