protected $categorySetupFactory;
public function __construct(
...
\Magento\Catalog\Setup\CategorySetupFactory $categorySetupFactory
....
) {
....
$this->categorySetupFactory = $categorySetupFactory;
....
}
Now In your setup file you can use this like,
$setup = $this->categorySetupFactory->create(['setup' => $setup]);
$setup->addAttribute(
\Magento\Catalog\Model\Category::ENTITY, 'custom_image', [
'type' => 'varchar',
'label' => 'Custom Image',
'input' => 'image',
'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image',
'required' => false,
'sort_order' => 9,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General Information',
]
);