# Image File Tool Sample Code

The following sample code creates an ImageFileTool object and imports a bitmap image:

    // 8 grey image
    const std::string filePath = initialWorkingDirectory_ + "\\images\\blobs.bmp";

    // Create an ImageFile tool and set it to Read
    auto imageFileTool = Cognex::VisionPro::Object::Create<Cognex::VisionPro::ImageFile::ImageFileTool>();
    imageFileTool->Operator()->Open(filePath, Cognex::VisionPro::ImageFile::ImageFileModeConstants::Read);

    // Run the tool to get an image from the image-database file.
    ImageFileTool->Run();

    // Get the output image from the ImageFile tool
    const auto nextImage = imageFileTool->OutputImage();